New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@vyft/docker

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vyft/docker - npm Package Compare versions

Comparing version
0.0.0
to
0.2.0-alpha
+33
dist/caddy.d.ts
import type { DockerClient } from "./client.ts";
interface CaddyRoute {
match: Array<{
host?: string[];
path?: string[];
}>;
handle: Array<{
handler: string;
upstreams?: Array<{
dial: string;
}>;
routes?: CaddyRoute[];
}>;
}
interface CaddyConfig {
apps: {
http: {
servers: Record<string, {
listen: string[];
routes: CaddyRoute[];
}>;
};
};
}
export declare function buildCaddyConfig(services: Array<{
host: string;
port: number;
route?: string;
domain?: string;
}>): CaddyConfig;
export declare function pushCaddyConfig(client: DockerClient, caddyContainerName: string, config: CaddyConfig): Promise<void>;
export {};
//# sourceMappingURL=caddy.d.ts.map
{"version":3,"file":"caddy.d.ts","sourceRoot":"","sources":["../src/caddy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,UAAU,UAAU;IAClB,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IACnD,MAAM,EAAE,KAAK,CAAC;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QACpC,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;KACvB,CAAC,CAAC;CACJ;AAED,UAAU,WAAW;IACnB,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE;gBAAE,MAAM,EAAE,MAAM,EAAE,CAAC;gBAAC,MAAM,EAAE,UAAU,EAAE,CAAA;aAAE,CAAC,CAAC;SACrE,CAAC;KACH,CAAC;CACH;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC,GACD,WAAW,CA4Bb;AAED,wBAAsB,eAAe,CACnC,MAAM,EAAE,YAAY,EACpB,kBAAkB,EAAE,MAAM,EAC1B,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
export function buildCaddyConfig(services) {
const routes = services.map((svc) => ({
match: [
{
...(svc.domain ? { host: [svc.domain] } : {}),
...(svc.route ? { path: [`${svc.route}*`] } : {}),
},
],
handle: [
{
handler: "reverse_proxy",
upstreams: [{ dial: `${svc.host}:${svc.port}` }],
},
],
}));
return {
apps: {
http: {
servers: {
srv0: {
listen: [":80"],
routes,
},
},
},
},
};
}
export async function pushCaddyConfig(client, caddyContainerName, config) {
// Caddy admin API listens on :2019 inside the container
// We exec into the container to push config via localhost
const execRes = await client.post(`/containers/${caddyContainerName}/exec`, {
Cmd: [
"wget",
"-q",
"-O-",
"--post-data",
JSON.stringify(config),
"--header",
"Content-Type: application/json",
"http://localhost:2019/load",
],
AttachStdout: true,
AttachStderr: true,
});
if (execRes.status === 201) {
await client.post(`/exec/${execRes.body.Id}/start`, {
Detach: false,
Tty: false,
});
}
}
//# sourceMappingURL=caddy.js.map
{"version":3,"file":"caddy.js","sourceRoot":"","sources":["../src/caddy.ts"],"names":[],"mappings":"AAmBA,MAAM,UAAU,gBAAgB,CAC9B,QAKE;IAEF,MAAM,MAAM,GAAiB,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAClD,KAAK,EAAE;YACL;gBACE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CA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CAAC;AACH,CAAC"}
export interface DockerResponse<T = unknown> {
status: number;
body: T;
}
export interface DockerClient {
get<T = unknown>(path: string): Promise<DockerResponse<T>>;
post<T = unknown>(path: string, body?: unknown): Promise<DockerResponse<T>>;
del<T = unknown>(path: string): Promise<DockerResponse<T>>;
}
export declare function createClient(socketPath?: string): DockerClient;
//# sourceMappingURL=client.d.ts.map
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;CACT;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;CAC5D;AAkDD,wBAAgB,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,YAAY,CAe9D"}
import http from "node:http";
const API_VERSION = "/v1.47";
function request(socketPath, method, path, body) {
return new Promise((resolve, reject) => {
const payload = body !== undefined ? JSON.stringify(body) : undefined;
const req = http.request({
socketPath,
path: `${API_VERSION}${path}`,
method,
headers: {
"Content-Type": "application/json",
...(payload !== undefined
? { "Content-Length": Buffer.byteLength(payload) }
: {}),
},
}, (res) => {
const chunks = [];
res.on("data", (chunk) => chunks.push(chunk));
res.on("end", () => {
const raw = Buffer.concat(chunks).toString("utf8");
let parsed;
try {
parsed = JSON.parse(raw);
}
catch {
parsed = raw;
}
resolve({ status: res.statusCode ?? 0, body: parsed });
});
res.on("error", reject);
});
req.on("error", reject);
if (payload !== undefined) {
req.write(payload);
}
req.end();
});
}
export function createClient(socketPath) {
const sock = socketPath ?? process.env["DOCKER_HOST"] ?? "/var/run/docker.sock";
return {
get(path) {
return request(sock, "GET", path);
},
post(path, body) {
return request(sock, "POST", path, body);
},
del(path) {
return request(sock, "DELETE", path);
},
};
}
//# sourceMappingURL=client.js.map
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAa7B,MAAM,WAAW,GAAG,QAAQ,CAAC;AAE7B,SAAS,OAAO,CACd,UAAkB,EAClB,MAAc,EACd,IAAY,EACZ,IAAc;IAEd,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAEtE,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CACtB;YACE,UAAU;YACV,IAAI,EAAE,GAAG,WAAW,GAAG,IAAI,EAAE;YAC7B,MAAM;YACN,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,GAAG,CAAC,OAAO,KAAK,SAAS;oBACvB,CAAC,CAAC,EAAE,gBAAgB,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;oBAClD,CAAC,CAAC,EAAE,CAAC;aACR;SACF,EACD,CAAC,GAAG,EAAE,EAAE;YACN,MAAM,MAAM,GAAa,EAAE,CAAC;YAC5B,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YACtD,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE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erClient } from "./index.ts";
interface ContainerInput {
port: number;
env?: Record<string, string> | undefined;
command?: string[] | undefined;
mounts?: Array<{
source: string;
target: string;
}> | undefined;
health?: {
path: string;
interval?: string | undefined;
timeout?: string | undefined;
retries?: number | undefined;
} | undefined;
restart?: string | undefined;
}
export declare function containerName(project: string, stage: string, id: string): string;
interface HostConfig {
RestartPolicy: {
Name: string;
};
NetworkMode: string;
Binds?: string[];
}
interface ContainerConfig {
Image: string;
Env: string[];
ExposedPorts: Record<string, object>;
HostConfig: HostConfig;
Labels: Record<string, string>;
Cmd?: string[];
Healthcheck?: {
Test: string[];
Interval?: number;
Timeout?: number;
Retries?: number;
};
}
export declare function buildContainerConfig(input: ContainerInput, name: string, image: string, ctx: {
project: string;
stage: string;
networkName: string;
}): ContainerConfig;
export declare function createContainer(client: DockerClient, name: string, config: ContainerConfig): Promise<string>;
export declare function removeContainer(client: DockerClient, name: string): Promise<void>;
export declare function recreateContainer(client: DockerClient, name: string, config: ContainerConfig): Promise<string>;
export {};
//# sourceMappingURL=container.d.ts.map
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/client/container.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC/B,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,SAAS,CAAC;IAC/D,MAAM,CAAC,EACH;QACE,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7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,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAGf;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC,CAGjB"}
import { durationToNanos } from "@vyft/runtime";
export function containerName(project, stage, id) {
return `vyft-${project}-${stage}-${id}`;
}
export function buildContainerConfig(input, name, image, ctx) {
const baseEnv = { NODE_ENV: ctx.stage, ...input.env };
const env = Object.entries(baseEnv).map(([k, v]) => `${k}=${v}`);
const labels = {
"com.docker.compose.project": ctx.project,
"com.docker.compose.service": name,
"vyft.project": ctx.project,
"vyft.stage": ctx.stage,
"vyft.managed": "true",
};
const config = {
Image: image,
Env: env,
ExposedPorts: { [`${input.port}/tcp`]: {} },
HostConfig: {
RestartPolicy: { Name: input.restart ?? "always" },
NetworkMode: ctx.networkName,
},
Labels: labels,
};
if (input.command) {
config.Cmd = input.command;
}
if (input.mounts && input.mounts.length > 0) {
config.HostConfig.Binds = input.mounts.map((m) => `${m.source}:${m.target}`);
}
if (input.health) {
config.Healthcheck = {
Test: [
"CMD-SHELL",
`curl -f http://localhost:${input.port}${input.health.path} || exit 1`,
],
};
if (input.health.interval !== undefined) {
config.Healthcheck.Interval = durationToNanos(input.health.interval);
}
if (input.health.timeout !== undefined) {
config.Healthcheck.Timeout = durationToNanos(input.health.timeout);
}
if (input.health.retries !== undefined) {
config.Healthcheck.Retries = input.health.retries;
}
}
return config;
}
export async function createContainer(client, name, config) {
let res = await client.post(`/containers/create?name=${encodeURIComponent(name)}`, config);
if (res.status === 409) {
await removeContainer(client, name);
res = await client.post(`/containers/create?name=${encodeURIComponent(name)}`, config);
}
if (res.status !== 201) {
throw new Error(`Failed to create container ${name}: ${res.status}`);
}
await client.post(`/containers/${res.body.Id}/start`);
return res.body.Id;
}
export async function removeContainer(client, name) {
await client.post(`/containers/${name}/stop`).catch(() => { });
await client.del(`/containers/${name}?force=true`);
}
export async function recreateContainer(client, name, config) {
await removeContainer(client, name);
return createContainer(client, name, config);
}
//# sourceMappingURL=container.js.map
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/client/container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAmBhD,MAAM,UAAU,aAAa,CAC3B,OAAe,EACf,KAAa,EACb,EAAU;IAEV,OAAO,QAAQ,OAAO,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;AAC1C,CAAC;AAuBD,MAAM,UAAU,oBAAoB,CAClC,KAAqB,EACrB,IAAY,EACZ,KAAa,EACb,GAA4D;IAE5D,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;IACtD,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEjE,MAAM,MAAM,GAA2B;QACrC,4BAA4B,EAAE,GAAG,CAAC,OAAO;QACzC,4BAA4B,EAAE,IAAI;QAClC,cAAc,EAAE,GAAG,CAAC,OAAO;QAC3B,YAAY,EAAE,GAAG,CAAC,KAAK;QACvB,cAAc,EAAE,MAAM;KACvB,CAAC;IAEF,MAAM,MAAM,GAAoB;QAC9B,KAAK,EAAE,KAAK;QACZ,GAAG,EAAE,GAAG;QACR,YAAY,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,MAAM,CAAC,EAAE,EAAE,EAAE;QAC3C,UAAU,EAAE;YACV,aAAa,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,IAAI,QAAQ,EAAE;YAClD,WAAW,EAAE,GAAG,CAAC,WAAW;SAC7B;QACD,MAAM,EAAE,MAAM;KACf,CAAC;IA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M,MAAM,CAAC,IAAI,CACzB,2BAA2B,kBAAkB,CAAC,IAAI,CAAC,EAAE,EACrD,MAAM,CACP,CAAC;IAEF,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,MAAM,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACpC,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CACrB,2BAA2B,kBAAkB,CAAC,IAAI,CAAC,EAAE,EACrD,MAAM,CACP,CAAC;IACJ,CAAC;IAED,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAI,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,MAAM,CAAC,IAAI,CAAC,eAAe,GAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;IACtD,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;AACrB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAoB,EACpB,IAAY;IAEZ,MAAM,MAAM,CAAC,IAAI,CAAC,eAAe,IAAI,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC9D,MAAM,MAAM,CAAC,GAAG,CAAC,eAAe,IAAI,aAAa,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAoB,EACpB,IAAY,EACZ,MAAuB;IAEvB,MAAM,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACpC,OAAO,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC"}
import type { DockerClient } from "./index.ts";
export declare function pullImage(client: DockerClient, image: string): Promise<void>;
//# sourceMappingURL=image.d.ts.map
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/client/image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAsB,SAAS,CAC7B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAYf"}
export async function pullImage(client, image) {
const [name, tag] = image.includes(":")
? [image.slice(0, image.indexOf(":")), image.slice(image.indexOf(":") + 1)]
: [image, "latest"];
const res = await client.post(`/images/create?fromImage=${encodeURIComponent(name)}&tag=${encodeURIComponent(tag)}`);
if (res.status !== 200) {
throw new Error(`Failed to pull image ${image}: ${res.status}`);
}
}
//# sourceMappingURL=image.js.map
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../src/client/image.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAoB,EACpB,KAAa;IAEb,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QACrC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3E,CAAC,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAEtB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAC3B,4BAA4B,kBAAkB,CAAC,IAAI,CAAC,QAAQ,kBAAkB,CAAC,GAAG,CAAC,EAAE,CACtF,CAAC;IAEF,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IAClE,CAAC;AACH,CAAC"}
export interface DockerResponse<T = unknown> {
status: number;
body: T;
}
export interface DockerClient {
get<T = unknown>(path: string): Promise<DockerResponse<T>>;
post<T = unknown>(path: string, body?: unknown): Promise<DockerResponse<T>>;
del<T = unknown>(path: string): Promise<DockerResponse<T>>;
}
export declare function createClient(socketPath?: string): DockerClient;
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;CACT;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;CAC5D;AAkDD,wBAAgB,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,YAAY,CAe9D"}
import http from "node:http";
const API_VERSION = "/v1.47";
function request(socketPath, method, path, body) {
return new Promise((resolve, reject) => {
const payload = body !== undefined ? JSON.stringify(body) : undefined;
const req = http.request({
socketPath,
path: `${API_VERSION}${path}`,
method,
headers: {
"Content-Type": "application/json",
...(payload !== undefined
? { "Content-Length": Buffer.byteLength(payload) }
: {}),
},
}, (res) => {
const chunks = [];
res.on("data", (chunk) => chunks.push(chunk));
res.on("end", () => {
const raw = Buffer.concat(chunks).toString("utf8");
let parsed;
try {
parsed = JSON.parse(raw);
}
catch {
parsed = raw;
}
resolve({ status: res.statusCode ?? 0, body: parsed });
});
res.on("error", reject);
});
req.on("error", reject);
if (payload !== undefined) {
req.write(payload);
}
req.end();
});
}
export function createClient(socketPath) {
const sock = socketPath ?? process.env["DOCKER_HOST"] ?? "/var/run/docker.sock";
return {
get(path) {
return request(sock, "GET", path);
},
post(path, body) {
return request(sock, "POST", path, body);
},
del(path) {
return request(sock, "DELETE", path);
},
};
}
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAa7B,MAAM,WAAW,GAAG,QAAQ,CAAC;AAE7B,SAAS,OAAO,CACd,UAAkB,EAClB,MAAc,EACd,IAAY,EACZ,IAAc;IAEd,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAEtE,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CACtB;YACE,UAAU;YACV,IAAI,EAAE,GAAG,WAAW,GAAG,IAAI,EAAE;YAC7B,MAAM;YACN,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,GAAG,CAAC,OAAO,KAAK,SAAS;oBACvB,CAAC,CAAC,EAAE,gBAAgB,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;oBAClD,CAAC,CAAC,EAAE,CAAC;aACR;SACF,EACD,CAAC,GAAG,EAAE,EAAE;YACN,MAAM,MAAM,GAAa,EAAE,CAAC;YAC5B,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YACtD,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;gBACjB,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBACnD,IAAI,MAAS,CAAC;gBACd,IAAI,CAAC;oBACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAM,CAAC;gBAChC,CAAC;gBAAC,MAAM,CAAC;oBACP,MAAM,GAAG,GAAQ,CAAC;gBACpB,CAAC;gBACD,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,UAAU,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;YACzD,CAAC,CAAC,CAAC;YACH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC1B,CAAC,CACF,CAAC;QAEF,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACxB,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;QACD,GAAG,CAAC,GAAG,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,UAAmB;IAC9C,MAAM,IAAI,GACR,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,sBAAsB,CAAC;IAErE,OAAO;QACL,GAAG,CAAI,IAAY;YACjB,OAAO,OAAO,CAAI,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,CAAI,IAAY,EAAE,IAAc;YAClC,OAAO,OAAO,CAAI,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAC9C,CAAC;QACD,GAAG,CAAI,IAAY;YACjB,OAAO,OAAO,CAAI,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC1C,CAAC;KACF,CAAC;AACJ,CAAC"}
import type { ServiceInput } from "@vyft/runtime";
import type { DockerClient } from "./index.ts";
interface DockerInspect {
Id: string;
Name: string;
Config: {
Image: string;
Env: string[];
Cmd?: string[];
ExposedPorts?: Record<string, object>;
Labels?: Record<string, string>;
};
HostConfig: {
RestartPolicy?: {
Name: string;
};
Binds?: string[];
NetworkMode?: string;
};
State: {
Status: string;
Running: boolean;
};
}
export declare function inspectContainer(client: DockerClient, name: string): Promise<DockerInspect | undefined>;
export declare function normalizeDockerContainer(inspect: DockerInspect): Partial<ServiceInput>;
export {};
//# sourceMappingURL=inspect.d.ts.map
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/client/inspect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,EAAE,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACjC,CAAC;IACF,UAAU,EAAE;QACV,aAAa,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;QACjC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,KAAK,EAAE;QACL,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CACH;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAIpC;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAqCvB"}
export async function inspectContainer(client, name) {
const res = await client.get(`/containers/${name}/json`);
if (res.status !== 200)
return undefined;
return res.body;
}
export function normalizeDockerContainer(inspect) {
const env = {};
for (const e of inspect.Config.Env) {
const idx = e.indexOf("=");
if (idx > 0) {
env[e.slice(0, idx)] = e.slice(idx + 1);
}
}
const ports = Object.keys(inspect.Config.ExposedPorts ?? {});
const portStr = ports[0];
const port = portStr
? Number.parseInt(portStr.split("/")[0] ?? "3000", 10)
: 3000;
const mounts = inspect.HostConfig.Binds?.map((b) => {
const [source = "", target = ""] = b.split(":");
return { source, target };
});
const restartName = inspect.HostConfig.RestartPolicy?.Name;
const restartPolicy = restartName === "always" ||
restartName === "on-failure" ||
restartName === "unless-stopped" ||
restartName === "no"
? restartName
: "always";
return {
image: inspect.Config.Image,
port,
env,
command: inspect.Config.Cmd ?? undefined,
mounts: mounts && mounts.length > 0 ? mounts : undefined,
restart: restartPolicy,
};
}
//# sourceMappingURL=inspect.js.map
{"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../src/client/inspect.ts"],"names":[],"mappings":"AAwBA,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAoB,EACpB,IAAY;IAEZ,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAgB,eAAe,IAAI,OAAO,CAAC,CAAC;IACxE,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;QAAE,OAAO,SAAS,CAAC;IACzC,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,OAAsB;IAEtB,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACnC,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;YACZ,GAAG,C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CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;QACxD,OAAO,EAAE,aAAa;KACvB,CAAC;AACJ,CAAC"}
export {};
//# sourceMappingURL=inspect.test.d.ts.map
{"version":3,"file":"inspect.test.d.ts","sourceRoot":"","sources":["../../src/client/inspect.test.ts"],"names":[],"mappings":""}
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { normalizeDockerContainer } from "./inspect.js";
const baseInspect = {
Id: "abc123",
Name: "/test",
Config: {
Image: "nginx:latest",
Env: [],
ExposedPorts: { "80/tcp": {} },
},
HostConfig: {},
State: { Status: "running", Running: true },
};
describe("normalizeDockerContainer", () => {
it("parses a simple bind mount without options", () => {
const result = normalizeDockerContainer({
...baseInspect,
HostConfig: { Binds: ["/host/data:/container/data"] },
});
assert.deepEqual(result.mounts, [
{ source: "/host/data", target: "/container/data" },
]);
});
it("strips mount options like :ro from target path", () => {
const result = normalizeDockerContainer({
...baseInspect,
HostConfig: { Binds: ["/host/data:/container/data:ro"] },
});
assert.deepEqual(result.mounts, [
{ source: "/host/data", target: "/container/data" },
]);
});
it("handles multiple bind mounts with mixed options", () => {
const result = normalizeDockerContainer({
...baseInspect,
HostConfig: {
Binds: [
"/host/a:/container/a:ro",
"/host/b:/container/b",
"/host/c:/container/c:rw,z",
],
},
});
assert.deepEqual(result.mounts, [
{ source: "/host/a", target: "/container/a" },
{ source: "/host/b", target: "/container/b" },
{ source: "/host/c", target: "/container/c" },
]);
});
it("returns undefined mounts when Binds is empty", () => {
const result = normalizeDockerContainer({
...baseInspect,
HostConfig: { Binds: [] },
});
assert.equal(result.mounts, undefined);
});
it("returns undefined mounts when Binds is absent", () => {
const result = normalizeDockerContainer({
...baseInspect,
HostConfig: {},
});
assert.equal(result.mounts, undefined);
});
it("handles malformed bind string with no colon", () => {
const result = normalizeDockerContainer({
...baseInspect,
HostConfig: { Binds: ["orphan"] },
});
assert.deepEqual(result.mounts, [{ source: "orphan", target: "" }]);
});
});
//# sourceMappingURL=inspect.test.js.map
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AAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
import type { DockerClient } from "./index.ts";
export declare function ensureNetwork(client: DockerClient, name: string): Promise<string>;
//# sourceMappingURL=network.d.ts.map
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/client/network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAO/C,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CAoBjB"}
export async function ensureNetwork(client, name) {
const existing = await client.get(`/networks?filters=${encodeURIComponent(JSON.stringify({ name: [name] }))}`);
if (existing.status === 200 && Array.isArray(existing.body)) {
const exact = existing.body.find((n) => n.Name === name);
if (exact)
return exact.Id;
}
const res = await client.post("/networks/create", {
Name: name,
Driver: "bridge",
});
if (res.status !== 201) {
throw new Error(`Failed to create network ${name}: ${res.status}`);
}
return res.body.Id;
}
//# sourceMappingURL=network.js.map
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/client/network.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAoB,EACpB,IAAY;IAEZ,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAC/B,qBAAqB,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAC5E,CAAC;IAEF,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5D,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QACzD,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC,EAAE,CAAC;IAC7B,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAiB,kBAAkB,EAAE;QAChE,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,QAAQ;KACjB,CAAC,CAAC;IAEH,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;AACrB,CAAC"}
import type { DockerClient } from "./index.ts";
export declare function createVolume(client: DockerClient, name: string): Promise<void>;
export declare function removeVolume(client: DockerClient, name: string): Promise<void>;
//# sourceMappingURL=volume.d.ts.map
{"version":3,"file":"volume.d.ts","sourceRoot":"","sources":["../../src/client/volume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAsB,YAAY,CAChC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAQf;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAEf"}
export async function createVolume(client, name) {
const res = await client.post("/volumes/create", {
Name: name,
Driver: "local",
});
if (res.status !== 201) {
throw new Error(`Failed to create volume ${name}: ${res.status}`);
}
}
export async function removeVolume(client, name) {
await client.del(`/volumes/${name}`);
}
//# sourceMappingURL=volume.js.map
{"version":3,"file":"volume.js","sourceRoot":"","sources":["../../src/client/volume.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAoB,EACpB,IAAY;IAEZ,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE;QAC/C,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,OAAO;KAChB,CAAC,CAAC;IACH,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IACpE,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAoB,EACpB,IAAY;IAEZ,MAAM,MAAM,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;AACvC,CAAC"}
import type { DockerClient } from "./client.ts";
import type { DockerContext } from "./context.ts";
interface ContainerInput {
port: number;
env?: Record<string, string> | undefined;
command?: string[] | undefined;
mounts?: Array<{
source: string;
target: string;
}> | undefined;
health?: {
path: string;
interval?: string | undefined;
timeout?: string | undefined;
retries?: number | undefined;
} | undefined;
restart?: string | undefined;
}
export declare function containerName(project: string, stage: string, id: string): string;
interface HostConfig {
RestartPolicy: {
Name: string;
};
NetworkMode: string;
Binds?: string[];
}
interface ContainerConfig {
Image: string;
Env: string[];
ExposedPorts: Record<string, object>;
HostConfig: HostConfig;
Labels: Record<string, string>;
Cmd?: string[];
Healthcheck?: {
Test: string[];
Interval?: number;
Timeout?: number;
Retries?: number;
};
}
export declare function buildContainerConfig(input: ContainerInput, name: string, image: string, ctx: DockerContext): ContainerConfig;
export declare function createContainer(client: DockerClient, name: string, config: ContainerConfig): Promise<string>;
export declare function removeContainer(client: DockerClient, name: string): Promise<void>;
export declare function recreateContainer(client: DockerClient, name: string, config: ContainerConfig): Promise<string>;
export {};
//# sourceMappingURL=container.d.ts.map
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD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E,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,aAAa,GACjB,eAAe,CA6CjB;AAMD,wBAAsB,eAAe,CACnC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC,CAsBjB;AAED,wBAAsB,eAAe,CACnC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAGf;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC,CAGjB"}
export function containerName(project, stage, id) {
return `vyft-${project}-${stage}-${id}`;
}
export function buildContainerConfig(input, name, image, ctx) {
const env = Object.entries(input.env ?? {}).map(([k, v]) => `${k}=${v}`);
const labels = {
"com.docker.compose.project": ctx.project,
"com.docker.compose.service": name,
"vyft.project": ctx.project,
"vyft.stage": ctx.stage,
"vyft.managed": "true",
};
const config = {
Image: image,
Env: env,
ExposedPorts: { [`${input.port}/tcp`]: {} },
HostConfig: {
RestartPolicy: { Name: input.restart ?? "always" },
NetworkMode: ctx.networkName,
},
Labels: labels,
};
if (input.command) {
config.Cmd = input.command;
}
if (input.mounts && input.mounts.length > 0) {
config.HostConfig.Binds = input.mounts.map((m) => `${m.source}:${m.target}`);
}
if (input.health) {
config.Healthcheck = {
Test: [
"CMD-SHELL",
`curl -f http://localhost:${input.port}${input.health.path} || exit 1`,
],
};
if (input.health.retries !== undefined) {
config.Healthcheck.Retries = input.health.retries;
}
}
return config;
}
export async function createContainer(client, name, config) {
let res = await client.post(`/containers/create?name=${encodeURIComponent(name)}`, config);
if (res.status === 409) {
await removeContainer(client, name);
res = await client.post(`/containers/create?name=${encodeURIComponent(name)}`, config);
}
if (res.status !== 201) {
throw new Error(`Failed to create container ${name}: ${res.status} ${JSON.stringify(res.body)}`);
}
await client.post(`/containers/${res.body.Id}/start`);
return res.body.Id;
}
export async function removeContainer(client, name) {
await client.post(`/containers/${name}/stop`).catch(() => { });
await client.del(`/containers/${name}?force=true`);
}
export async function recreateContainer(client, name, config) {
await removeContainer(client, name);
return createContainer(client, name, config);
}
//# sourceMappingURL=container.js.map
{"version":3,"file":"container.js","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAmBA,MAAM,UAAU,aAAa,CAC3B,OAAe,EACf,KAAa,EACb,EAAU;IAEV,OAAO,QAAQ,OAAO,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;AAC1C,CAAC;AAuBD,MAAM,UAAU,oBAAoB,CAClC,KAAqB,EACrB,IAAY,EACZ,KAAa,EACb,GAAkB;IAElB,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEzE,MAAM,MAAM,GAA2B;QACrC,4BAA4B,EAAE,GAAG,CAAC,OAAO;QACzC,4BAA4B,EAAE,IAAI;QAClC,cAAc,EAAE,GAAG,CAAC,OAAO;QAC3B,YAAY,EAAE,GAAG,CAAC,KAAK;QACvB,cAAc,EAAE,MAAM;KACvB,CAAC;IAEF,MAAM,MAAM,GAAoB;QAC9B,KAAK,EAAE,KAAK;QACZ,GAAG,EAAE,GAAG;QACR,YAAY,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,MAAM,CAAC,EAAE,EAAE,EAAE;QAC3C,UAAU,EAAE;YACV,aAAa,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,IAAI,QAAQ,EAAE;Y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AI,CAAC,EAAE,EACrD,MAAM,CACP,CAAC;IACJ,CAAC;IAED,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,8BAA8B,IAAI,KAAK,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAChF,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,CAAC,IAAI,CAAC,eAAe,GAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;IACtD,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;AACrB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAoB,EACpB,IAAY;IAEZ,MAAM,MAAM,CAAC,IAAI,CAAC,eAAe,IAAI,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC9D,MAAM,MAAM,CAAC,GAAG,CAAC,eAAe,IAAI,aAAa,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAoB,EACpB,IAAY,EACZ,MAAuB;IAEvB,MAAM,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACpC,OAAO,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC"}
export declare function createContext(opts: {
project: string;
stage: string;
socketPath?: string;
}): {
client: import("./client/index.ts").DockerClient;
project: string;
stage: string;
networkName: string;
};
export type DockerContext = ReturnType<typeof createContext>;
//# sourceMappingURL=context.d.ts.map
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;;;;;EAOA;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC"}
import { createClient } from "./client/index.js";
export function createContext(opts) {
return {
client: createClient(opts.socketPath),
project: opts.project,
stage: opts.stage,
networkName: `vyft-${opts.project}-${opts.stage}`,
};
}
//# sourceMappingURL=context.js.map
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,UAAU,aAAa,CAAC,IAI7B;IACC,OAAO;QACL,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC;QACrC,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,QAAQ,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,EAAE;KAClD,CAAC;AACJ,CAAC"}
import type { Handlers } from "@vyft/core";
import type { CronJobInput } from "@vyft/runtime";
import type { DockerContext } from "./context.ts";
export declare const cronjobHandlers: Handlers<CronJobInput, DockerContext>;
//# sourceMappingURL=cronjob.d.ts.map
{"version":3,"file":"cronjob.d.ts","sourceRoot":"","sources":["../src/cronjob.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAUlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAWlD,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,YAAY,EAAE,aAAa,CAsEjE,CAAC"}
import { buildContainerConfig, containerName, createContainer, recreateContainer, removeContainer, } from "./client/container.js";
import { pullImage } from "./client/image.js";
import { ensureNetwork } from "./client/network.js";
function buildCronCommand(schedule, command) {
const crontab = `${schedule} ${command.join(" ")}`;
return [
"sh",
"-c",
`echo '${crontab}' > /tmp/crontab && supercronic /tmp/crontab`,
];
}
export const cronjobHandlers = {
async create({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
const image = input.image ?? "node:lts-slim";
await pullImage(ctx.client, image);
const serviceInput = {
image,
path: input.path,
cwd: input.cwd,
port: 0,
env: input.env,
command: input.command
? buildCronCommand(input.schedule, input.command)
: undefined,
mounts: input.mounts,
health: input.health,
restart: input.restart ?? "on-failure",
};
const config = buildContainerConfig(serviceInput, name, image, ctx);
const containerId = await createContainer(ctx.client, name, config);
return {
output: {
name,
containerId,
},
};
},
async update({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
const image = input.image ?? "node:lts-slim";
const serviceInput = {
image,
path: input.path,
cwd: input.cwd,
port: 0,
env: input.env,
command: input.command
? buildCronCommand(input.schedule, input.command)
: undefined,
mounts: input.mounts,
health: input.health,
restart: input.restart ?? "on-failure",
};
const config = buildContainerConfig(serviceInput, name, image, ctx);
const containerId = await recreateContainer(ctx.client, name, config);
return {
name,
containerId,
};
},
async delete({ input, ctx }) {
const name = containerName(ctx.project, ctx.stage, input.name);
await removeContainer(ctx.client, name);
},
async diff() {
return { action: "recreate" };
},
};
//# sourceMappingURL=cronjob.js.map
{"version":3,"file":"cronjob.js","sourceRoot":"","sources":["../src/cronjob.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,SAAS,gBAAgB,CAAC,QAAgB,EAAE,OAAiB;IAC3D,MAAM,OAAO,GAAG,GAAG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACnD,OAAO;QACL,IAAI;QACJ,IAAI;QACJ,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ACR,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC;CACF,CAAC"}
import type { DockerClient } from "./client.ts";
export declare function pullImage(client: DockerClient, image: string): Promise<void>;
//# sourceMappingURL=image.d.ts.map
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../src/image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,wBAAsB,SAAS,CAC7B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAYf"}
export async function pullImage(client, image) {
const [name, tag] = image.includes(":")
? [image.slice(0, image.indexOf(":")), image.slice(image.indexOf(":") + 1)]
: [image, "latest"];
const res = await client.post(`/images/create?fromImage=${encodeURIComponent(name)}&tag=${encodeURIComponent(tag)}`);
if (res.status !== 200) {
throw new Error(`Failed to pull image ${image}: ${res.status}`);
}
}
//# sourceMappingURL=image.js.map
{"version":3,"file":"image.js","sourceRoot":"","sources":["../src/image.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAoB,EACpB,KAAa;IAEb,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QACrC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3E,CAAC,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAEtB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAC3B,4BAA4B,kBAAkB,CAAC,IAAI,CAAC,QAAQ,kBAAkB,CAAC,GAAG,CAAC,EAAE,CACtF,CAAC;IAEF,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IAClE,CAAC;AACH,CAAC"}
export { createContext as createDockerContext } from "./context.ts";
export { default } from "./provider.ts";
export { postgresHandlers } from "./resource/postgres.ts";
export { redisHandlers } from "./resource/redis.ts";
export { siteHandlers } from "./resource/site.ts";
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
export { createContext as createDockerContext } from "./context.js";
export { default } from "./provider.js";
export { postgresHandlers } from "./resource/postgres.js";
export { redisHandlers } from "./resource/redis.js";
export { siteHandlers } from "./resource/site.js";
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
import type { ServiceInput } from "@vyft/runtime";
import type { DockerClient } from "./client.ts";
interface DockerInspect {
Id: string;
Name: string;
Config: {
Image: string;
Env: string[];
Cmd?: string[];
ExposedPorts?: Record<string, object>;
Labels?: Record<string, string>;
};
HostConfig: {
RestartPolicy?: {
Name: string;
};
Binds?: string[];
NetworkMode?: string;
};
State: {
Status: string;
Running: boolean;
};
}
export declare function inspectContainer(client: DockerClient, name: string): Promise<DockerInspect | undefined>;
export declare function normalizeDockerContainer(inspect: DockerInspect): Partial<ServiceInput>;
export {};
//# sourceMappingURL=inspect.d.ts.map
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../src/inspect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,EAAE,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACjC,CAAC;IACF,UAAU,EAAE;QACV,aAAa,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;QACjC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,KAAK,EAAE;QACL,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CACH;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAIpC;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CA8BvB"}
export async function inspectContainer(client, name) {
const res = await client.get(`/containers/${name}/json`);
if (res.status !== 200)
return undefined;
return res.body;
}
export function normalizeDockerContainer(inspect) {
const env = {};
for (const e of inspect.Config.Env) {
const idx = e.indexOf("=");
if (idx > 0) {
env[e.slice(0, idx)] = e.slice(idx + 1);
}
}
const ports = Object.keys(inspect.Config.ExposedPorts ?? {});
const portStr = ports[0];
const port = portStr
? Number.parseInt(portStr.split("/")[0] ?? "3000", 10)
: 3000;
const mounts = inspect.HostConfig.Binds?.map((b) => {
const idx = b.indexOf(":");
return { source: b.slice(0, idx), target: b.slice(idx + 1) };
});
return {
image: inspect.Config.Image,
port,
env,
command: inspect.Config.Cmd ?? undefined,
mounts: mounts && mounts.length > 0 ? mounts : undefined,
restart: inspect.HostConfig.RestartPolicy?.Name ??
"always",
};
}
//# sourceMappingURL=inspect.js.map
{"version":3,"file":"inspect.js","sourceRoot":"","sources":["../src/inspect.ts"],"names":[],"mappings":"AAwBA,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAoB,EACpB,IAAY;IAEZ,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAgB,eAAe,IAAI,OAAO,CAAC,CAAC;IACxE,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;QAAE,OAAO,SAAS,CAAC;IACzC,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,OAAsB;IAEtB,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACnC,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;YACZ,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,IAAI,GAAG,OAAO;QAClB,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,EAAE,CAAC;QACtD,CAAC,CAAC,IAAI,CAAC;IAET,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACjD,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3B,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC;IAC/D,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK;QAC3B,IAAI;QACJ,GAAG;QACH,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,SAAS;QACxC,MAAM,EAAE,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;QACxD,OAAO,EACJ,OAAO,CAAC,UAAU,CAAC,aAAa,EAAE,IAAgC;YACnE,QAAQ;KACX,CAAC;AACJ,CAAC"}
import type { DockerClient } from "./client.ts";
export declare function ensureNetwork(client: DockerClient, name: string): Promise<string>;
//# sourceMappingURL=network.d.ts.map
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAOhD,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CAoBjB"}
export async function ensureNetwork(client, name) {
const existing = await client.get(`/networks?filters=${encodeURIComponent(JSON.stringify({ name: [name] }))}`);
if (existing.status === 200 && Array.isArray(existing.body)) {
const exact = existing.body.find((n) => n.Name === name);
if (exact)
return exact.Id;
}
const res = await client.post("/networks/create", {
Name: name,
Driver: "bridge",
});
if (res.status !== 201) {
throw new Error(`Failed to create network ${name}: ${res.status}`);
}
return res.body.Id;
}
//# sourceMappingURL=network.js.map
{"version":3,"file":"network.js","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAoB,EACpB,IAAY;IAEZ,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAC/B,qBAAqB,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAC5E,CAAC;IAEF,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5D,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QACzD,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC,EAAE,CAAC;IAC7B,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAiB,kBAAkB,EAAE;QAChE,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,QAAQ;KACjB,CAAC,CAAC;IAEH,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;AACrB,CAAC"}
declare const _default: (opts: {
project: string;
stage: string;
socketPath?: string;
}) => import("@vyft/core").Provider<{
client: import("./client/index.ts").DockerClient;
project: string;
stage: string;
networkName: string;
}>;
export default _default;
//# sourceMappingURL=provider.d.ts.map
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":";;;;;;;;;;AAOA,wBASG"}
import { defineRuntime } from "@vyft/runtime";
import { createContext } from "./context.js";
import { cronjobHandlers } from "./resource/cronjob.js";
import { jobHandlers } from "./resource/job.js";
import { serviceHandlers } from "./resource/service.js";
import { volumeHandlers } from "./resource/volume.js";
export default defineRuntime({
name: "docker",
context: createContext,
handlers: {
service: serviceHandlers,
job: jobHandlers,
volume: volumeHandlers,
cronjob: cronjobHandlers,
},
});
//# sourceMappingURL=provider.js.map
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,eAAe,aAAa,CAAC;IAC3B,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE;QACR,OAAO,EAAE,eAAe;QACxB,GAAG,EAAE,WAAW;QAChB,MAAM,EAAE,cAAc;QACtB,OAAO,EAAE,eAAe;KACzB;CACF,CAAC,CAAC"}
import type { DockerContext } from "./context.ts";
export declare function ensureProxy(ctx: DockerContext): Promise<string>;
export declare function deployProxy(ctx: DockerContext, services: Array<{
host: string;
port: number;
route?: string;
domain?: string;
}>): Promise<void>;
export declare function removeProxy(ctx: DockerContext): Promise<void>;
//# sourceMappingURL=proxy.d.ts.map
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAOlD,wBAAsB,WAAW,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBrE;AAED,wBAAsB,WAAW,CAC/B,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC,GACD,OAAO,CAAC,IAAI,CAAC,CAKf;AAED,wBAAsB,WAAW,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAGnE"}
import { buildCaddyConfig, pushCaddyConfig } from "./caddy.js";
import { buildContainerConfig, containerName, createContainer, removeContainer, } from "./container.js";
import { inspectContainer } from "./inspect.js";
import { ensureNetwork } from "./network.js";
const PROXY_ID = "proxy";
const CADDY_IMAGE = "caddy:2-alpine";
export async function ensureProxy(ctx) {
const name = containerName(ctx.project, ctx.stage, PROXY_ID);
const existing = await inspectContainer(ctx.client, name);
if (existing)
return existing.Id;
await ensureNetwork(ctx.client, ctx.networkName);
const config = buildContainerConfig({
port: 80,
restart: "always",
env: {},
}, name, CADDY_IMAGE, ctx);
return createContainer(ctx.client, name, config);
}
export async function deployProxy(ctx, services) {
const name = containerName(ctx.project, ctx.stage, PROXY_ID);
await ensureProxy(ctx);
const caddyConfig = buildCaddyConfig(services);
await pushCaddyConfig(ctx.client, name, caddyConfig);
}
export async function removeProxy(ctx) {
const name = containerName(ctx.project, ctx.stage, PROXY_ID);
await removeContainer(ctx.client, name);
}
//# sourceMappingURL=proxy.js.map
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,QAAQ,GAAG,OAAO,CAAC;AACzB,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAErC,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAkB;IAClD,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC1D,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC,EAAE,CAAC;IAEjC,MAAM,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IAEjD,MAAM,MAAM,GAAG,oBAAoB,CACjC;QACE,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,QAAQ;QACjB,GAAG,EAAE,EAAE;KACR,EACD,IAAI,EACJ,WAAW,EACX,GAAG,CACJ,CAAC;IAEF,OAAO,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,GAAkB,EAClB,QAKE;IAEF,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC7D,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;IACvB,MAAM,WAAW,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAkB;IAClD,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC7D,MAAM,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC1C,CAAC"}
import type { Handlers } from "@vyft/core";
import type { CronJobInput } from "@vyft/runtime";
import type { DockerContext } from "../context.ts";
export declare const cronjobHandlers: Handlers<CronJobInput, DockerContext>;
//# sourceMappingURL=cronjob.d.ts.map
{"version":3,"file":"cronjob.d.ts","sourceRoot":"","sources":["../../src/resource/cronjob.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAWlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAWnD,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,YAAY,EAAE,aAAa,CA6EjE,CAAC"}
import { buildContainerConfig, containerName, createContainer, recreateContainer, removeContainer, } from "../client/container.js";
import { pullImage } from "../client/image.js";
import { inspectContainer } from "../client/inspect.js";
import { ensureNetwork } from "../client/network.js";
function buildCronCommand(schedule, command) {
const crontab = `${schedule} ${command.join(" ")}`;
return [
"sh",
"-c",
`echo '${crontab}' > /tmp/crontab && supercronic /tmp/crontab`,
];
}
export const cronjobHandlers = {
async create({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
const image = input.image ?? "node:lts-slim";
await pullImage(ctx.client, image);
const serviceInput = {
image,
path: input.path,
cwd: input.cwd,
port: 0,
env: input.env,
command: input.command
? buildCronCommand(input.schedule, input.command)
: undefined,
mounts: input.mounts,
health: input.health,
restart: input.restart ?? "on-failure",
};
const config = buildContainerConfig(serviceInput, name, image, ctx);
const containerId = await createContainer(ctx.client, name, config);
return {
output: {
name,
containerId,
},
};
},
async read({ input, ctx }) {
const name = containerName(ctx.project, ctx.stage, input.name);
const inspect = await inspectContainer(ctx.client, name);
if (!inspect)
return {};
return { name, containerId: inspect.Id };
},
async update({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
const image = input.image ?? "node:lts-slim";
const serviceInput = {
image,
path: input.path,
cwd: input.cwd,
port: 0,
env: input.env,
command: input.command
? buildCronCommand(input.schedule, input.command)
: undefined,
mounts: input.mounts,
health: input.health,
restart: input.restart ?? "on-failure",
};
const config = buildContainerConfig(serviceInput, name, image, ctx);
const containerId = await recreateContainer(ctx.client, name, config);
return {
name,
containerId,
};
},
async delete({ input, ctx }) {
const name = containerName(ctx.project, ctx.stage, input.name);
await removeContainer(ctx.client, name);
},
async diff() {
return { action: "recreate" };
},
};
//# sourceMappingURL=cronjob.js.map
{"version":3,"file":"cronjob.js","sourceRoot":"","sources":["../../src/resource/cronjob.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,SAAS,gBAAgB,CAAC,QAAgB,EAAE,OAAiB;IAC3D,MAAM,OAAO,GAAG,GAAG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,C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AG,CAAC,CAAC;QACpE,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAEtE,OAAO;YACL,IAAI;YACJ,WAAW;SACZ,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/D,MAAM,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC;CACF,CAAC"}
import type { Handlers } from "@vyft/core";
import type { JobInput } from "@vyft/runtime";
import type { DockerContext } from "../context.ts";
export declare const jobHandlers: Handlers<JobInput, DockerContext>;
//# sourceMappingURL=job.d.ts.map
{"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../../src/resource/job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAU9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,QAAQ,EAAE,aAAa,CA4EzD,CAAC"}
import { buildContainerConfig, containerName, createContainer, recreateContainer, removeContainer, } from "../client/container.js";
import { pullImage } from "../client/image.js";
import { ensureNetwork } from "../client/network.js";
export const jobHandlers = {
async create({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
const image = input.image ?? "node:lts-slim";
await pullImage(ctx.client, image);
const config = buildContainerConfig({
port: 0,
env: input.env,
command: input.command,
mounts: input.mounts,
restart: "no",
}, name, image, ctx);
const containerId = await createContainer(ctx.client, name, config);
// Wait for the container to finish
const res = await ctx.client.post(`/containers/${containerId}/wait`);
return {
output: {
name,
exitCode: res.body.StatusCode,
containerId,
},
};
},
async update({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
const image = input.image ?? "node:lts-slim";
await pullImage(ctx.client, image);
const config = buildContainerConfig({
port: 0,
env: input.env,
command: input.command,
mounts: input.mounts,
restart: "no",
}, name, image, ctx);
const containerId = await recreateContainer(ctx.client, name, config);
const res = await ctx.client.post(`/containers/${containerId}/wait`);
return {
name,
exitCode: res.body.StatusCode,
containerId,
};
},
async delete({ input, ctx }) {
const name = containerName(ctx.project, ctx.stage, input.name);
await removeContainer(ctx.client, name);
},
async diff() {
return { action: "recreate" };
},
};
//# sourceMappingURL=job.js.map
{"version":3,"file":"job.js","sourceRoot":"","sources":["../../src/resource/job.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,MAAM,CAAC,MAAM,WAAW,GAAsC;IAC5D,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;QAEjD,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,eAAe,CAAC;QAC7C,MAAM,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC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W,GAAG,MAAM,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAEtE,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAC/B,eAAe,WAAW,OAAO,CAClC,CAAC;QAEF,OAAO;YACL,IAAI;YACJ,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,UAAU;YAC7B,WAAW;SACZ,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/D,MAAM,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC;CACF,CAAC"}
import type { Handlers } from "@vyft/core";
import type { PostgresArgs } from "@vyft/platform";
import type { DockerContext } from "../context.ts";
type PostgresInput = PostgresArgs & {
name: string;
};
export declare const postgresHandlers: Handlers<PostgresInput, DockerContext>;
export {};
//# sourceMappingURL=postgres.d.ts.map
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../src/resource/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAUnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,KAAK,aAAa,GAAG,YAAY,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAiBrD,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,aAAa,EAAE,aAAa,CA2EnE,CAAC"}
import { containerName, createContainer, recreateContainer, removeContainer, } from "../client/container.js";
import { pullImage } from "../client/image.js";
import { inspectContainer } from "../client/inspect.js";
import { ensureNetwork } from "../client/network.js";
const DEFAULT_PORT = 5432;
function image(version) {
return `postgres:${version ?? "16"}`;
}
function labels(ctx, name) {
return {
"vyft.project": ctx.project,
"vyft.stage": ctx.stage,
"vyft.managed": "true",
"vyft.resource": name,
};
}
export const postgresHandlers = {
async create({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
const img = image(input.version);
await pullImage(ctx.client, img);
const containerId = await createContainer(ctx.client, name, {
Image: img,
Env: ["POSTGRES_HOST_AUTH_METHOD=trust"],
ExposedPorts: { [`${DEFAULT_PORT}/tcp`]: {} },
HostConfig: {
RestartPolicy: { Name: "always" },
NetworkMode: ctx.networkName,
},
Labels: labels(ctx, name),
});
return {
output: {
host: name,
port: DEFAULT_PORT,
url: `postgresql://postgres@${name}:${DEFAULT_PORT}/postgres`,
containerId,
},
};
},
async read({ input, ctx }) {
const name = containerName(ctx.project, ctx.stage, input.name);
const inspect = await inspectContainer(ctx.client, name);
if (!inspect)
return {};
return {
host: name,
port: DEFAULT_PORT,
url: `postgresql://postgres@${name}:${DEFAULT_PORT}/postgres`,
containerId: inspect.Id,
};
},
async update({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
const img = image(input.version);
await pullImage(ctx.client, img);
const containerId = await recreateContainer(ctx.client, name, {
Image: img,
Env: ["POSTGRES_HOST_AUTH_METHOD=trust"],
ExposedPorts: { [`${DEFAULT_PORT}/tcp`]: {} },
HostConfig: {
RestartPolicy: { Name: "always" },
NetworkMode: ctx.networkName,
},
Labels: labels(ctx, name),
});
return {
host: name,
port: DEFAULT_PORT,
url: `postgresql://postgres@${name}:${DEFAULT_PORT}/postgres`,
containerId,
};
},
async delete({ input, ctx }) {
const name = containerName(ctx.project, ctx.stage, input.name);
await removeContainer(ctx.client, name);
},
async diff() {
return { action: "recreate" };
},
};
//# sourceMappingURL=postgres.js.map
{"version":3,"file":"postgres.js","sourceRoot":"","sources":["../../src/resource/postgres.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAKrD,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B,SAAS,KAAK,CAAC,OAAgB;IAC7B,OAAO,YAAY,OAAO,IAAI,IAAI,EAAE,CAAC;AACvC,CAAC;AAED,SAAS,MAAM,CAAC,GAAkB,EAAE,IAAY;IAC9C,OAAO;QACL,cAAc,EAAE,GAAG,CAAC,OAAO;QAC3B,YAAY,EAAE,GAAG,CAAC,KAAK;QACvB,cAAc,EAAE,MAAM;QACtB,eAAe,EAAE,IAAI;KACtB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAA2C;IACtE,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;QAEjD,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/D,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACjC,MAAM,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAEjC,MAAM,WAAW,GAAG,MAAM,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE;YAC1D,KAAK,EAAE,GAAG;YACV,GAAG,EAAE,CA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O,CAAC,CAAC;QACjC,MAAM,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAEjC,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE;YAC5D,KAAK,EAAE,GAAG;YACV,GAAG,EAAE,CAAC,iCAAiC,CAAC;YACxC,YAAY,EAAE,EAAE,CAAC,GAAG,YAAY,MAAM,CAAC,EAAE,EAAE,EAAE;YAC7C,UAAU,EAAE;gBACV,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACjC,WAAW,EAAE,GAAG,CAAC,WAAW;aAC7B;YACD,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC;SAC1B,CAAC,CAAC;QAEH,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,YAAY;YAClB,GAAG,EAAE,yBAAyB,IAAI,IAAI,YAAY,WAAW;YAC7D,WAAW;SACZ,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/D,MAAM,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC;CACF,CAAC"}
import type { Handlers } from "@vyft/core";
import type { RedisArgs } from "@vyft/platform";
import type { DockerContext } from "../context.ts";
type RedisInput = RedisArgs & {
name: string;
};
export declare const redisHandlers: Handlers<RedisInput, DockerContext>;
export {};
//# sourceMappingURL=redis.d.ts.map
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/resource/redis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAUhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,KAAK,UAAU,GAAG,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAiB/C,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,UAAU,EAAE,aAAa,CA2E7D,CAAC"}
import { containerName, createContainer, recreateContainer, removeContainer, } from "../client/container.js";
import { pullImage } from "../client/image.js";
import { inspectContainer } from "../client/inspect.js";
import { ensureNetwork } from "../client/network.js";
const DEFAULT_PORT = 6379;
function image(version) {
return `redis:${version ?? "7"}`;
}
function labels(ctx, name) {
return {
"vyft.project": ctx.project,
"vyft.stage": ctx.stage,
"vyft.managed": "true",
"vyft.resource": name,
};
}
export const redisHandlers = {
async create({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
const img = image(input.version);
await pullImage(ctx.client, img);
const containerId = await createContainer(ctx.client, name, {
Image: img,
Env: [],
ExposedPorts: { [`${DEFAULT_PORT}/tcp`]: {} },
HostConfig: {
RestartPolicy: { Name: "always" },
NetworkMode: ctx.networkName,
},
Labels: labels(ctx, name),
});
return {
output: {
host: name,
port: DEFAULT_PORT,
url: `redis://${name}:${DEFAULT_PORT}`,
containerId,
},
};
},
async read({ input, ctx }) {
const name = containerName(ctx.project, ctx.stage, input.name);
const inspect = await inspectContainer(ctx.client, name);
if (!inspect)
return {};
return {
host: name,
port: DEFAULT_PORT,
url: `redis://${name}:${DEFAULT_PORT}`,
containerId: inspect.Id,
};
},
async update({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
const img = image(input.version);
await pullImage(ctx.client, img);
const containerId = await recreateContainer(ctx.client, name, {
Image: img,
Env: [],
ExposedPorts: { [`${DEFAULT_PORT}/tcp`]: {} },
HostConfig: {
RestartPolicy: { Name: "always" },
NetworkMode: ctx.networkName,
},
Labels: labels(ctx, name),
});
return {
host: name,
port: DEFAULT_PORT,
url: `redis://${name}:${DEFAULT_PORT}`,
containerId,
};
},
async delete({ input, ctx }) {
const name = containerName(ctx.project, ctx.stage, input.name);
await removeContainer(ctx.client, name);
},
async diff() {
return { action: "recreate" };
},
};
//# sourceMappingURL=redis.js.map
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../src/resource/redis.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAKrD,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B,SAAS,KAAK,CAAC,OAAgB;IAC7B,OAAO,SAAS,OAAO,IAAI,GAAG,EAAE,CAAC;AACnC,CAAC;AAED,SAAS,MAAM,CAAC,GAAkB,EAAE,IAAY;IAC9C,OAAO;QACL,cAAc,EAAE,GAAG,CAAC,OAAO;QAC3B,YAAY,EAAE,GAAG,CAAC,KAAK;QACvB,cAAc,EAAE,MAAM;QACtB,eAAe,EAAE,IAAI;KACtB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAwC;IAChE,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;QAEjD,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/D,MAAM,GAAG,GAAG,KAAK,CAAC,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AAG,CAAC,WAAW,CAAC,CAAC;QAEjD,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/D,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACjC,MAAM,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAEjC,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE;YAC5D,KAAK,EAAE,GAAG;YACV,GAAG,EAAE,EAAE;YACP,YAAY,EAAE,EAAE,CAAC,GAAG,YAAY,MAAM,CAAC,EAAE,EAAE,EAAE;YAC7C,UAAU,EAAE;gBACV,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACjC,WAAW,EAAE,GAAG,CAAC,WAAW;aAC7B;YACD,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC;SAC1B,CAAC,CAAC;QAEH,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,YAAY;YAClB,GAAG,EAAE,WAAW,IAAI,IAAI,YAAY,EAAE;YACtC,WAAW;SACZ,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/D,MAAM,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC;CACF,CAAC"}
import type { Handlers } from "@vyft/core";
import type { ServiceInput } from "@vyft/runtime";
import type { DockerContext } from "../context.ts";
export declare const serviceHandlers: Handlers<ServiceInput, DockerContext>;
//# sourceMappingURL=service.d.ts.map
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/resource/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAclD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,YAAY,EAAE,aAAa,CA2DjE,CAAC"}
import { buildContainerConfig, containerName, createContainer, recreateContainer, removeContainer, } from "../client/container.js";
import { pullImage } from "../client/image.js";
import { inspectContainer, normalizeDockerContainer, } from "../client/inspect.js";
import { ensureNetwork } from "../client/network.js";
export const serviceHandlers = {
async create({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
const image = input.image ?? "node:lts-slim";
await pullImage(ctx.client, image);
const config = buildContainerConfig(input, name, image, ctx);
const containerId = await createContainer(ctx.client, name, config);
return {
output: {
host: name,
port: input.port,
url: `http://${name}:${input.port}`,
containerId,
},
};
},
async read({ input, ctx }) {
const name = containerName(ctx.project, ctx.stage, input.name);
const inspect = await inspectContainer(ctx.client, name);
if (!inspect)
return {};
const normalized = normalizeDockerContainer(inspect);
return {
...normalized,
host: name,
port: input.port,
url: `http://${name}:${input.port}`,
containerId: inspect.Id,
};
},
async update({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
const image = input.image ?? "node:lts-slim";
await pullImage(ctx.client, image);
const config = buildContainerConfig(input, name, image, ctx);
const containerId = await recreateContainer(ctx.client, name, config);
return {
host: name,
port: input.port,
url: `http://${name}:${input.port}`,
containerId,
};
},
async delete({ input, ctx }) {
const name = containerName(ctx.project, ctx.stage, input.name);
await removeContainer(ctx.client, name);
},
async diff() {
return { action: "recreate" };
},
};
//# sourceMappingURL=service.js.map
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/resource/service.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,MAAM,CAAC,MAAM,eAAe,GAA0C;IACpE,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;QAEjD,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,eAAe,CAAC;QAC7C,MAAM,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACnC,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QAC7D,MAAM,WAAW,GAAG,MAAM,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAEpE,OAAO;YACL,MAAM,EAAE;gBACN,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,GAAG,EAAE,UAAU,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE;gBACnC,WAAW;aACZ;SACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACvB,MAAM,IA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,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/D,MAAM,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC;CACF,CAAC"}
import type { Handlers } from "@vyft/core";
import type { SiteArgs } from "@vyft/platform";
import type { DockerContext } from "../context.ts";
type SiteInput = SiteArgs & {
name: string;
};
export declare const siteHandlers: Handlers<SiteInput, DockerContext>;
export {};
//# sourceMappingURL=site.d.ts.map
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../../src/resource/site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAU/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,KAAK,SAAS,GAAG,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAc7C,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,SAAS,EAAE,aAAa,CA8E3D,CAAC"}
import { containerName, createContainer, recreateContainer, removeContainer, } from "../client/container.js";
import { pullImage } from "../client/image.js";
import { inspectContainer } from "../client/inspect.js";
import { ensureNetwork } from "../client/network.js";
const DEFAULT_PORT = 80;
const IMAGE = "nginx:alpine";
function labels(ctx, name) {
return {
"vyft.project": ctx.project,
"vyft.stage": ctx.stage,
"vyft.managed": "true",
"vyft.resource": name,
};
}
export const siteHandlers = {
async create({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
await pullImage(ctx.client, IMAGE);
const containerId = await createContainer(ctx.client, name, {
Image: IMAGE,
Env: [],
ExposedPorts: { [`${DEFAULT_PORT}/tcp`]: {} },
HostConfig: {
RestartPolicy: { Name: "always" },
NetworkMode: ctx.networkName,
Binds: input.path ? [`${input.path}:/usr/share/nginx/html:ro`] : [],
},
Labels: labels(ctx, name),
});
return {
output: {
host: name,
port: DEFAULT_PORT,
url: `http://${name}:${DEFAULT_PORT}`,
domain: input.domain,
containerId,
},
};
},
async read({ input, ctx }) {
const name = containerName(ctx.project, ctx.stage, input.name);
const inspect = await inspectContainer(ctx.client, name);
if (!inspect)
return {};
return {
host: name,
port: DEFAULT_PORT,
url: `http://${name}:${DEFAULT_PORT}`,
domain: input.domain,
containerId: inspect.Id,
};
},
async update({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
await pullImage(ctx.client, IMAGE);
const containerId = await recreateContainer(ctx.client, name, {
Image: IMAGE,
Env: [],
ExposedPorts: { [`${DEFAULT_PORT}/tcp`]: {} },
HostConfig: {
RestartPolicy: { Name: "always" },
NetworkMode: ctx.networkName,
Binds: input.path ? [`${input.path}:/usr/share/nginx/html:ro`] : [],
},
Labels: labels(ctx, name),
});
return {
host: name,
port: DEFAULT_PORT,
url: `http://${name}:${DEFAULT_PORT}`,
domain: input.domain,
containerId,
};
},
async delete({ input, ctx }) {
const name = containerName(ctx.project, ctx.stage, input.name);
await removeContainer(ctx.client, name);
},
async diff() {
return { action: "recreate" };
},
};
//# sourceMappingURL=site.js.map
{"version":3,"file":"site.js","sourceRoot":"","sources":["../../src/resource/site.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;A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AAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACjC,WAAW,EAAE,GAAG,CAAC,WAAW;gBAC5B,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,2BAA2B,CAAC,CAAC,CAAC,CAAC,EAAE;aACpE;YACD,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC;SAC1B,CAAC,CAAC;QAEH,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,YAAY;YAClB,GAAG,EAAE,UAAU,IAAI,IAAI,YAAY,EAAE;YACrC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,WAAW;SACZ,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/D,MAAM,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC;CACF,CAAC"}
import type { Handlers } from "@vyft/core";
import type { VolumeInput } from "@vyft/runtime";
import type { DockerContext } from "../context.ts";
export declare const volumeHandlers: Handlers<VolumeInput, DockerContext>;
//# sourceMappingURL=volume.d.ts.map
{"version":3,"file":"volume.d.ts","sourceRoot":"","sources":["../../src/resource/volume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAMnD,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,EAAE,aAAa,CAsB/D,CAAC"}
import { createVolume, removeVolume } from "../client/volume.js";
function volumeName(project, stage, id) {
return `vyft-${project}-${stage}-${id}`;
}
export const volumeHandlers = {
async create({ input, ctx }) {
const name = volumeName(ctx.project, ctx.stage, input.name);
await createVolume(ctx.client, name);
return { output: { name } };
},
async read({ input, ctx }) {
const name = volumeName(ctx.project, ctx.stage, input.name);
const res = await ctx.client.get(`/volumes/${name}`);
if (res.status !== 200)
return {};
return { name };
},
async delete({ input, ctx }) {
const name = volumeName(ctx.project, ctx.stage, input.name);
await removeVolume(ctx.client, name);
},
async diff() {
return { action: "none" };
},
};
//# sourceMappingURL=volume.js.map
{"version":3,"file":"volume.js","sourceRoot":"","sources":["../../src/resource/volume.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGjE,SAAS,UAAU,CAAC,OAAe,EAAE,KAAa,EAAE,EAAU;IAC5D,OAAO,QAAQ,OAAO,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;AAC1C,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAyC;IAClE,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5D,MAAM,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACrC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACvB,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5D,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;QACrD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;YAAE,OAAO,EAAE,CAAC;QAClC,OAAO,EAAE,IAAI,EAAE,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5D,MAAM,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF,CAAC"}
import type { Handlers } from "@vyft/core";
import type { ServiceInput } from "@vyft/runtime";
import type { DockerContext } from "./context.ts";
export declare const serviceHandlers: Handlers<ServiceInput, DockerContext>;
//# sourceMappingURL=service.d.ts.map
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAWlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,YAAY,EAAE,aAAa,CA2DjE,CAAC"}
import { buildContainerConfig, containerName, createContainer, recreateContainer, removeContainer, } from "./client/container.js";
import { pullImage } from "./client/image.js";
import { inspectContainer, normalizeDockerContainer } from "./client/inspect.js";
import { ensureNetwork } from "./client/network.js";
export const serviceHandlers = {
async create({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
const image = input.image ?? "node:lts-slim";
await pullImage(ctx.client, image);
const config = buildContainerConfig(input, name, image, ctx);
const containerId = await createContainer(ctx.client, name, config);
return {
output: {
host: name,
port: input.port,
url: `http://${name}:${input.port}`,
containerId,
},
};
},
async read({ input, ctx }) {
const name = containerName(ctx.project, ctx.stage, input.name);
const inspect = await inspectContainer(ctx.client, name);
if (!inspect)
return {};
const normalized = normalizeDockerContainer(inspect);
return {
...normalized,
host: name,
port: input.port,
url: `http://${name}:${input.port}`,
containerId: inspect.Id,
};
},
async update({ input, ctx }) {
await ensureNetwork(ctx.client, ctx.networkName);
const name = containerName(ctx.project, ctx.stage, input.name);
const image = input.image ?? "node:lts-slim";
await pullImage(ctx.client, image);
const config = buildContainerConfig(input, name, image, ctx);
const containerId = await recreateContainer(ctx.client, name, config);
return {
host: name,
port: input.port,
url: `http://${name}:${input.port}`,
containerId,
};
},
async delete({ input, ctx }) {
const name = containerName(ctx.project, ctx.stage, input.name);
await removeContainer(ctx.client, name);
},
async diff() {
return { action: "recreate" };
},
};
//# sourceMappingURL=service.js.map
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,MAAM,CAAC,MAAM,eAAe,GAA0C;IACpE,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;QAEjD,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/D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AI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,eAAe,CAAC;QAC7C,MAAM,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACnC,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QAC7D,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAEtE,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,GAAG,EAAE,UAAU,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE;YACnC,WAAW;SACZ,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/D,MAAM,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC;CACF,CAAC"}
import type { Handlers } from "@vyft/core";
import type { VolumeInput } from "@vyft/runtime";
import type { DockerContext } from "./context.ts";
export declare const volumeHandlers: Handlers<VolumeInput, DockerContext>;
//# sourceMappingURL=volume.d.ts.map
{"version":3,"file":"volume.d.ts","sourceRoot":"","sources":["../src/volume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAMlD,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,EAAE,aAAa,CAsB/D,CAAC"}
import { createVolume, removeVolume } from "./client/volume.js";
function volumeName(project, stage, id) {
return `vyft-${project}-${stage}-${id}`;
}
export const volumeHandlers = {
async create({ input, ctx }) {
const name = volumeName(ctx.project, ctx.stage, input.name);
await createVolume(ctx.client, name);
return { output: { name } };
},
async read({ input, ctx }) {
const name = volumeName(ctx.project, ctx.stage, input.name);
const res = await ctx.client.get(`/volumes/${name}`);
if (res.status !== 200)
return {};
return { name };
},
async delete({ input, ctx }) {
const name = volumeName(ctx.project, ctx.stage, input.name);
await removeVolume(ctx.client, name);
},
async diff() {
return { action: "none" };
},
};
//# sourceMappingURL=volume.js.map
{"version":3,"file":"volume.js","sourceRoot":"","sources":["../src/volume.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGhE,SAAS,UAAU,CAAC,OAAe,EAAE,KAAa,EAAE,EAAU;IAC5D,OAAO,QAAQ,OAAO,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;AAC1C,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAyC;IAClE,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5D,MAAM,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACrC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACvB,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5D,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;QACrD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;YAAE,OAAO,EAAE,CAAC;QAClC,OAAO,EAAE,IAAI,EAAE,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5D,MAAM,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF,CAAC"}
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to the Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by the Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding any notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
Copyright 2025-present Vyft Labs
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
# @vyft/docker
> Docker runtime provider for Vyft.
Part of [Vyft](https://github.com/vyftlabs/vyft) — deploy apps with TypeScript.
+27
-1

@@ -1,1 +0,27 @@

{"name":"@vyft/docker","version":"0.0.0"}
{
"name": "@vyft/docker",
"version": "0.2.0-alpha",
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"dependencies": {
"@vyft/core": "0.2.0-alpha",
"@vyft/platform": "0.2.0-alpha",
"@vyft/runtime": "0.2.0-alpha"
},
"scripts": {
"build": "tsc",
"test": "node --test 'src/**/*.test.ts'",
"lint": "biome check ."
}
}