compose-as-code
Version:
Provides a module to express docker compose files as code
162 lines (161 loc) • 3.85 kB
TypeScript
import { Composition } from './composition';
import { Network } from './network';
import { Volume } from './volume';
export type ServiceVolume = {
containerLocation: string;
hostLocation: Volume | string;
accessMode?: 'rw' | 'ro' | 'z';
};
export type ServiceHealthCheck = {
test: string[];
interval: string;
timeout?: string;
retries: number;
start_period: string;
};
export type ServiceProps = {
image: string;
pullPolicy?: 'always' | 'if-not-present' | 'never';
restart?: 'always' | 'on-failure' | 'unless-stopped' | 'no';
expose?: string[];
ports?: string[];
cpuCount?: string;
cpuPercent?: string;
cpuShares?: string;
cpuPeriod?: string;
cpuQuota?: string;
cpuRtRuntime?: string;
cpuRtPeriod?: string;
cpuSet?: string;
healthCheck?: ServiceHealthCheck;
deviceReadBps?: {
path: string;
rate: number;
};
deviceWriteBps?: {
path: string;
rate: number;
};
deviceReadIops?: {
path: string;
rate: number;
};
deviceWriteIops?: {
path: string;
rate: number;
};
weight?: number;
weightDevice?: {
path: string;
weight: number;
};
securityOpt?: {
key: 'seccomp';
value: string;
}[];
capAdd?: string[];
capDrop?: string[];
cgroupParent?: string;
deploy?: {
mode?: 'global' | 'replicated';
resources?: {
limits?: {
cpus?: string;
memory?: string;
pids?: number;
};
reservations?: {
cpus?: string;
memory?: string;
};
};
labels?: {
[key: string]: string;
};
};
memReservation?: string;
memLimit?: string;
command?: string | string[];
containerName?: string;
entryPoint?: string;
dependsOn?: Service[];
environment?: {
[key: string]: string | number;
};
networks?: Network[];
volumes?: ServiceVolume[];
};
export declare class Service {
id: string;
image: string;
pullPolicy?: 'always' | 'if-not-present' | 'never';
restart?: 'always' | 'on-failure' | 'unless-stopped' | 'no';
expose?: string[];
ports?: string[];
cpuCount?: string;
cpuPercent?: string;
cpuShares?: string;
cpuPeriod?: string;
cpuQuota?: string;
cpuRtRuntime?: string;
cpuRtPeriod?: string;
cpuSet?: string;
healthCheck?: ServiceHealthCheck;
deviceReadBps?: {
path: string;
rate: number;
};
deviceWriteBps?: {
path: string;
rate: number;
};
deviceReadIops?: {
path: string;
rate: number;
};
deviceWriteIops?: {
path: string;
rate: number;
};
weight?: number;
weightDevice?: {
path: string;
weight: number;
};
capAdd?: string[];
capDrop?: string[];
cgroupParent?: string;
deploy?: {
mode?: 'global' | 'replicated';
resources?: {
limits?: {
cpus?: string;
memory?: string;
pids?: number;
};
reservations?: {
cpus?: string;
memory?: string;
};
};
labels?: {
[key: string]: string;
};
};
securityOpt?: {
key: 'seccomp';
value: string;
}[];
memReservation?: string;
memLimit?: string;
command?: string | string[];
containerName?: string;
entryPoint?: string;
dependsOn?: Service[];
environment?: {
[key: string]: string | number;
};
networks?: Network[];
volumes?: ServiceVolume[];
constructor(scope: Composition, logicalId: string, props: ServiceProps);
}