UNPKG

@wocker/core

Version:
80 lines (79 loc) 2.72 kB
import type Docker from "dockerode"; import type { Container, ImageInfo, VolumeCreateResponse } from "dockerode"; import { Duplex } from "node:stream"; export declare namespace DockerServiceParams { type CreateContainer = { name: string; image: string; user?: string; restart?: "always"; entrypoint?: string | string[]; projectId?: string; tty?: boolean; memory?: number; memorySwap?: number; ulimits?: { [key: string]: { hard?: number; soft?: number; }; }; links?: string[]; env?: { [key: string]: string; }; networkMode?: string; extraHosts?: any; volumes?: string[]; ports?: string[]; cmd?: string[]; network?: string; aliases?: string[]; }; type ImageList = { tag?: string; reference?: string[]; labels?: { [key: string]: string; }; }; type BuildImage = { version?: "1" | "2"; tag: string; buildArgs?: { [key: string]: string; }; labels?: { [key: string]: string; }; context: string | string[]; } & ({ /** @deprecated */ src: string; } | { dockerfile: string; }); type Exec = { cmd: string[]; tty?: boolean; user?: string; }; } export declare abstract class DockerService { abstract get docker(): Docker; abstract createContainer(params: DockerServiceParams.CreateContainer): Promise<Container>; abstract getContainer(name: string): Promise<Container | null>; abstract removeContainer(name: string): Promise<void>; abstract createVolume(name: string): Promise<VolumeCreateResponse>; abstract hasVolume(name: string): Promise<boolean>; abstract rmVolume(name: string): Promise<void>; abstract buildImage(params: DockerServiceParams.BuildImage): Promise<any>; abstract imageExists(tag: string): Promise<boolean>; abstract imageLs(options?: DockerServiceParams.ImageList): Promise<ImageInfo[]>; abstract imageRm(tag: string, force?: boolean): Promise<void>; abstract pullImage(tag: string): Promise<void>; abstract attach(name: string | Container): Promise<NodeJS.ReadWriteStream | null | undefined>; abstract attachStream(stream: NodeJS.ReadWriteStream): Promise<NodeJS.ReadWriteStream>; abstract exec(name: string, command?: DockerServiceParams.Exec | string[], tty?: boolean): Promise<Duplex | null>; abstract logs(containerOrName: string | Container): Promise<NodeJS.ReadableStream | null | undefined>; }