@xec-sh/core
Version:
Universal shell execution engine
54 lines (53 loc) • 2.3 kB
TypeScript
import type { ExecutionResult } from '../core/result.js';
import type { ProcessPromise, ExecutionEngine } from '../core/execution-engine.js';
import type { DockerAdapter, DockerLogsOptions, DockerHealthCheckOptions } from '../adapters/docker-adapter.js';
export interface DockerContainerConfig {
image: string;
name?: string;
volumes?: Record<string, string> | string[];
env?: Record<string, string>;
ports?: Record<string, string> | string[];
network?: string;
healthcheck?: DockerHealthCheckOptions;
restart?: 'no' | 'always' | 'unless-stopped' | 'on-failure';
command?: string | string[];
workdir?: string;
user?: string;
labels?: Record<string, string>;
privileged?: boolean;
}
export declare class DockerContainer {
private engine;
private adapter;
private config;
private containerName;
private isStarted;
private isRemoved;
constructor(engine: ExecutionEngine, adapter: DockerAdapter, config: DockerContainerConfig);
get name(): string;
get started(): boolean;
get removed(): boolean;
private isContainerCreated;
start(): Promise<DockerContainer>;
exec(strings: TemplateStringsArray, ...values: any[]): ProcessPromise;
execRaw(command: string, args?: string[]): Promise<ExecutionResult>;
logs(options?: DockerLogsOptions): Promise<string>;
streamLogs(onData: (data: string) => void, options?: DockerLogsOptions): Promise<void>;
follow(onData: (data: string) => void, options?: Omit<DockerLogsOptions, 'follow'>): Promise<void>;
stop(timeout?: number): Promise<void>;
remove(force?: boolean): Promise<void>;
restart(): Promise<void>;
waitForHealthy(timeout?: number): Promise<void>;
stats(): Promise<any>;
inspect(): Promise<any>;
copyTo(localPath: string, containerPath: string): Promise<void>;
copyFrom(containerPath: string, localPath: string): Promise<void>;
getIpAddress(network?: string): Promise<string | null>;
private formatVolumes;
private formatPorts;
}
export interface DockerContext {
start(): Promise<DockerContainer>;
(strings: TemplateStringsArray, ...values: any[]): ProcessPromise;
}
export declare function createDockerContext(engine: ExecutionEngine, config: DockerContainerConfig): DockerContext;