/*! * Copyright 2019-2020 Lime Technology Inc. All rights reserved. * Written by: Alexis Tyler */ import pify from 'pify'; import Docker from 'dockerode'; import { paths } from '../../paths'; // Borrowed from https://stackoverflow.com/a/52731696 until pify // adds their own types, check https://github.com/sindresorhus/pify/issues/74 type UnpackedPromise = T extends Promise ? U : T; type GenericFunction = (...args: TS) => R; type Promisify = { [K in keyof T]: T[K] extends GenericFunction ? (...args: TS) => Promise> : never }; const socketPath = paths.get('docker-socket') ?? '/var/run/docker.sock'; const client = new Docker({ socketPath }); /** * Docker client */ export const docker = pify(client) as unknown as Promisify;