@better-openclaw/core 1.0.19 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/dependabot.yml +32 -0
- package/.github/workflows/ci.yml +8 -8
- package/.github/workflows/publish-core.yml +4 -4
- package/SECURITY.md +62 -0
- package/dist/deployers/coolify.cjs +61 -50
- package/dist/deployers/coolify.cjs.map +1 -1
- package/dist/deployers/coolify.d.cts +4 -11
- package/dist/deployers/coolify.d.cts.map +1 -1
- package/dist/deployers/coolify.d.mts +4 -11
- package/dist/deployers/coolify.d.mts.map +1 -1
- package/dist/deployers/coolify.mjs +62 -50
- package/dist/deployers/coolify.mjs.map +1 -1
- package/dist/deployers/dokploy.cjs +106 -29
- package/dist/deployers/dokploy.cjs.map +1 -1
- package/dist/deployers/dokploy.d.cts +2 -1
- package/dist/deployers/dokploy.d.cts.map +1 -1
- package/dist/deployers/dokploy.d.mts +2 -1
- package/dist/deployers/dokploy.d.mts.map +1 -1
- package/dist/deployers/dokploy.mjs +107 -29
- package/dist/deployers/dokploy.mjs.map +1 -1
- package/dist/deployers/index.cjs.map +1 -1
- package/dist/deployers/index.d.cts +2 -2
- package/dist/deployers/index.d.cts.map +1 -1
- package/dist/deployers/index.d.mts +2 -2
- package/dist/deployers/index.d.mts.map +1 -1
- package/dist/deployers/index.mjs.map +1 -1
- package/dist/deployers/strip-host-ports.cjs +138 -0
- package/dist/deployers/strip-host-ports.cjs.map +1 -0
- package/dist/deployers/strip-host-ports.d.cts +62 -0
- package/dist/deployers/strip-host-ports.d.cts.map +1 -0
- package/dist/deployers/strip-host-ports.d.mts +62 -0
- package/dist/deployers/strip-host-ports.d.mts.map +1 -0
- package/dist/deployers/strip-host-ports.mjs +133 -0
- package/dist/deployers/strip-host-ports.mjs.map +1 -0
- package/dist/deployers/strip-host-ports.test.cjs +89 -0
- package/dist/deployers/strip-host-ports.test.cjs.map +1 -0
- package/dist/deployers/strip-host-ports.test.d.cts +1 -0
- package/dist/deployers/strip-host-ports.test.d.mts +1 -0
- package/dist/deployers/strip-host-ports.test.mjs +90 -0
- package/dist/deployers/strip-host-ports.test.mjs.map +1 -0
- package/dist/deployers/types.d.cts +173 -2
- package/dist/deployers/types.d.cts.map +1 -1
- package/dist/deployers/types.d.mts +173 -2
- package/dist/deployers/types.d.mts.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/services/definitions/usesend.cjs +4 -4
- package/dist/services/definitions/usesend.cjs.map +1 -1
- package/dist/services/definitions/usesend.mjs +4 -4
- package/dist/services/definitions/usesend.mjs.map +1 -1
- package/package.json +4 -4
- package/src/__snapshots__/composer.snapshot.test.ts.snap +248 -38
- package/src/deployers/coolify.ts +198 -103
- package/src/deployers/dokploy.ts +209 -55
- package/src/deployers/index.ts +1 -0
- package/src/deployers/strip-host-ports.test.ts +100 -0
- package/src/deployers/strip-host-ports.ts +187 -0
- package/src/deployers/types.ts +185 -1
- package/src/index.ts +19 -4
- package/src/services/definitions/usesend.ts +4 -4
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
import { sanitizeComposeForPaas } from "./strip-host-ports.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/deployers/dokploy.ts
|
|
4
|
+
/**
|
|
5
|
+
* Dokploy PaaS deployer — deploys Docker Compose stacks via the Dokploy REST API.
|
|
6
|
+
*
|
|
7
|
+
* API docs: https://docs.dokploy.com/docs/api
|
|
8
|
+
* Auth: x-api-key header
|
|
9
|
+
* Endpoints use dot-notation (e.g. /api/project.create, /api/compose.deploy)
|
|
10
|
+
*/
|
|
2
11
|
/** Build a full Dokploy API URL from a dot-notation endpoint (e.g. "project.create"). */
|
|
3
12
|
function apiUrl(target, endpoint) {
|
|
4
13
|
return `${target.instanceUrl.replace(/\/+$/, "")}/api/${endpoint}`;
|
|
@@ -30,6 +39,17 @@ async function dokployFetch(target, endpoint, options = {}) {
|
|
|
30
39
|
return JSON.parse(text);
|
|
31
40
|
}
|
|
32
41
|
/**
|
|
42
|
+
* Simple hash for compose diff detection
|
|
43
|
+
*/
|
|
44
|
+
function hashString(str) {
|
|
45
|
+
let hash = 0;
|
|
46
|
+
for (let i = 0; i < str.length; i++) {
|
|
47
|
+
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
48
|
+
hash |= 0;
|
|
49
|
+
}
|
|
50
|
+
return hash;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
33
53
|
* Deploys Docker Compose stacks to a Dokploy instance.
|
|
34
54
|
*
|
|
35
55
|
* Deploy flow (4 steps):
|
|
@@ -52,89 +72,147 @@ var DokployDeployer = class {
|
|
|
52
72
|
};
|
|
53
73
|
}
|
|
54
74
|
}
|
|
75
|
+
async listServers(target) {
|
|
76
|
+
try {
|
|
77
|
+
return (await dokployFetch(target, "server.all")).map((s) => ({
|
|
78
|
+
id: s.serverId,
|
|
79
|
+
name: s.name,
|
|
80
|
+
ip: s.ipAddress
|
|
81
|
+
}));
|
|
82
|
+
} catch {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
55
86
|
async deploy(input) {
|
|
56
87
|
const step1 = {
|
|
57
|
-
step: "
|
|
88
|
+
step: "Find or create project",
|
|
58
89
|
status: "pending"
|
|
59
90
|
};
|
|
60
91
|
const step2 = {
|
|
61
|
-
step: "
|
|
92
|
+
step: "Find default environment",
|
|
62
93
|
status: "pending"
|
|
63
94
|
};
|
|
64
95
|
const step3 = {
|
|
65
|
-
step: "
|
|
96
|
+
step: "Find or create compose stack",
|
|
66
97
|
status: "pending"
|
|
67
98
|
};
|
|
68
99
|
const step4 = {
|
|
69
|
-
step: "
|
|
100
|
+
step: "Update stack configuration",
|
|
101
|
+
status: "pending"
|
|
102
|
+
};
|
|
103
|
+
const step5 = {
|
|
104
|
+
step: "Deploy stack",
|
|
70
105
|
status: "pending"
|
|
71
106
|
};
|
|
72
107
|
const steps = [
|
|
73
108
|
step1,
|
|
74
109
|
step2,
|
|
75
110
|
step3,
|
|
76
|
-
step4
|
|
111
|
+
step4,
|
|
112
|
+
step5
|
|
77
113
|
];
|
|
78
114
|
const result = {
|
|
79
115
|
success: false,
|
|
80
116
|
steps
|
|
81
117
|
};
|
|
118
|
+
const composeYaml = sanitizeComposeForPaas(input.composeYaml);
|
|
82
119
|
try {
|
|
120
|
+
/**
|
|
121
|
+
* STEP 1
|
|
122
|
+
* Find or create project
|
|
123
|
+
*/
|
|
83
124
|
step1.status = "running";
|
|
84
|
-
|
|
125
|
+
let project = (await dokployFetch(input.target, "project.all")).find((p) => p.name === input.projectName);
|
|
126
|
+
if (!project) project = (await dokployFetch(input.target, "project.create", {
|
|
85
127
|
method: "POST",
|
|
86
128
|
body: {
|
|
87
129
|
name: input.projectName,
|
|
88
130
|
description: input.description ?? `OpenClaw stack: ${input.projectName}`
|
|
89
131
|
}
|
|
90
|
-
});
|
|
132
|
+
})).project;
|
|
91
133
|
result.projectId = project.projectId;
|
|
92
134
|
step1.status = "done";
|
|
93
135
|
step1.detail = `Project ID: ${project.projectId}`;
|
|
94
|
-
|
|
95
|
-
|
|
136
|
+
/**
|
|
137
|
+
* STEP 2
|
|
138
|
+
* Find default environment
|
|
139
|
+
*/
|
|
96
140
|
step2.status = "running";
|
|
97
|
-
const
|
|
141
|
+
const env = (await dokployFetch(input.target, `project.one?projectId=${project.projectId}`)).environments?.find((e) => e.isDefault);
|
|
142
|
+
if (!env) throw new Error("No default environment");
|
|
143
|
+
step2.status = "done";
|
|
144
|
+
step2.detail = env.environmentId;
|
|
145
|
+
/**
|
|
146
|
+
* STEP 3
|
|
147
|
+
* Find or create compose stack
|
|
148
|
+
*/
|
|
149
|
+
step3.status = "running";
|
|
150
|
+
let stack = null;
|
|
151
|
+
stack = await dokployFetch(input.target, "compose.create", {
|
|
98
152
|
method: "POST",
|
|
99
153
|
body: {
|
|
100
154
|
name: input.projectName,
|
|
101
|
-
|
|
102
|
-
|
|
155
|
+
description: input.description ?? `Stack ${input.projectName}`,
|
|
156
|
+
environmentId: env.environmentId,
|
|
157
|
+
composeType: "docker-compose",
|
|
158
|
+
composeFile: composeYaml,
|
|
159
|
+
...input.serverId ? { serverId: input.serverId } : {}
|
|
103
160
|
}
|
|
104
161
|
});
|
|
105
|
-
|
|
106
|
-
step2.status = "done";
|
|
107
|
-
step2.detail = `Compose ID: ${compose.composeId}`;
|
|
108
|
-
step3.status = "running";
|
|
109
|
-
await dokployFetch(input.target, "compose.update", {
|
|
162
|
+
if (stack?.composeId) await dokployFetch(input.target, "compose.update", {
|
|
110
163
|
method: "POST",
|
|
111
164
|
body: {
|
|
112
|
-
composeId:
|
|
113
|
-
|
|
165
|
+
composeId: stack.composeId,
|
|
166
|
+
sourceType: "raw"
|
|
114
167
|
}
|
|
115
168
|
});
|
|
169
|
+
result.composeId = stack?.composeId;
|
|
116
170
|
step3.status = "done";
|
|
171
|
+
step3.detail = stack?.composeId;
|
|
172
|
+
/**
|
|
173
|
+
* STEP 4
|
|
174
|
+
* Update stack if compose changed
|
|
175
|
+
*/
|
|
117
176
|
step4.status = "running";
|
|
177
|
+
const existingStack = await dokployFetch(input.target, `compose.one?composeId=${stack?.composeId}`);
|
|
178
|
+
if (hashString(composeYaml) !== hashString(existingStack.compose ?? "")) {
|
|
179
|
+
await dokployFetch(input.target, "compose.update", {
|
|
180
|
+
method: "POST",
|
|
181
|
+
body: {
|
|
182
|
+
composeId: stack?.composeId,
|
|
183
|
+
composeFile: composeYaml,
|
|
184
|
+
env: input.envContent ?? ""
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
step4.detail = "Stack updated";
|
|
188
|
+
} else step4.detail = "No compose changes";
|
|
189
|
+
step4.status = "done";
|
|
190
|
+
/**
|
|
191
|
+
* STEP 5
|
|
192
|
+
* Deploy
|
|
193
|
+
*/
|
|
194
|
+
step5.status = "running";
|
|
118
195
|
await dokployFetch(input.target, "compose.deploy", {
|
|
119
196
|
method: "POST",
|
|
120
197
|
body: {
|
|
121
|
-
composeId:
|
|
122
|
-
title: `
|
|
123
|
-
description:
|
|
198
|
+
composeId: stack?.composeId,
|
|
199
|
+
title: `Deploy ${input.projectName}`,
|
|
200
|
+
description: "CI deployment"
|
|
124
201
|
}
|
|
125
202
|
});
|
|
126
|
-
|
|
203
|
+
step5.status = "done";
|
|
127
204
|
result.success = true;
|
|
128
|
-
result.dashboardUrl = `${input.target.instanceUrl.replace(/\/+$/, "")}/dashboard/project/${project.projectId}`;
|
|
205
|
+
result.dashboardUrl = `${input.target.instanceUrl.replace(/\/+$/, "")}/dashboard/project/${project.projectId}/environment/${env.environmentId}/services/compose/${stack?.composeId}?tab=deployments`;
|
|
206
|
+
return result;
|
|
129
207
|
} catch (err) {
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
|
|
208
|
+
const running = steps.find((s) => s.status === "running");
|
|
209
|
+
if (running) {
|
|
210
|
+
running.status = "error";
|
|
211
|
+
running.detail = err instanceof Error ? err.message : String(err);
|
|
134
212
|
}
|
|
135
213
|
result.error = err instanceof Error ? err.message : String(err);
|
|
214
|
+
return result;
|
|
136
215
|
}
|
|
137
|
-
return result;
|
|
138
216
|
}
|
|
139
217
|
};
|
|
140
218
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dokploy.mjs","names":[],"sources":["../../src/deployers/dokploy.ts"],"sourcesContent":["/**\n * Dokploy PaaS deployer — deploys Docker Compose stacks via the Dokploy REST API.\n *\n * API docs: https://docs.dokploy.com/docs/api\n * Auth: x-api-key header\n * Endpoints use dot-notation (e.g. /api/project.create, /api/compose.deploy)\n */\n\nimport type { DeployInput, DeployResult, DeployStep, DeployTarget, PaasDeployer } from \"./types.js\";\n\n/** Shape returned by Dokploy's project endpoints. */\ninterface DokployProject {\n\tprojectId: string;\n\tname: string;\n\tdescription: string;\n\tenvironments?: { environmentId: string; name: string }[];\n}\n\n/** Shape returned by Dokploy's compose endpoints. */\ninterface DokployCompose {\n\tcomposeId: string;\n\tname: string;\n\tstatus?: string;\n}\n\n/** Build a full Dokploy API URL from a dot-notation endpoint (e.g. \"project.create\"). */\nfunction apiUrl(target: DeployTarget, endpoint: string): string {\n\tconst base = target.instanceUrl.replace(/\\/+$/, \"\");\n\treturn `${base}/api/${endpoint}`;\n}\n\n/**\n * Typed fetch wrapper for the Dokploy API.\n * Handles JSON serialisation, x-api-key auth, and error extraction.\n */\nasync function dokployFetch<T>(\n\ttarget: DeployTarget,\n\tendpoint: string,\n\toptions: { method?: string; body?: unknown } = {},\n): Promise<T> {\n\tconst res = await fetch(apiUrl(target, endpoint), {\n\t\tmethod: options.method ?? \"GET\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\"x-api-key\": target.apiKey,\n\t\t},\n\t\tbody: options.body ? JSON.stringify(options.body) : undefined,\n\t});\n\n\tif (!res.ok) {\n\t\tconst text = await res.text().catch(() => \"\");\n\t\tlet detail = text;\n\t\ttry {\n\t\t\tconst json = JSON.parse(text);\n\t\t\tdetail = json.message || json.error || text;\n\t\t} catch {\n\t\t\t// use raw text\n\t\t}\n\t\tthrow new Error(`Dokploy API ${res.status}: ${detail}`);\n\t}\n\n\tconst text = await res.text();\n\tif (!text) return undefined as T;\n\treturn JSON.parse(text) as T;\n}\n\n/**\n * Deploys Docker Compose stacks to a Dokploy instance.\n *\n * Deploy flow (4 steps):\n * 1. Create a Dokploy project\n * 2. Create a compose stack inside the project's default environment\n * 3. Push .env variables to the compose stack\n * 4. Trigger the deployment\n */\nexport class DokployDeployer implements PaasDeployer {\n\treadonly name = \"Dokploy\";\n\treadonly id = \"dokploy\";\n\n\tasync testConnection(target: DeployTarget): Promise<{ ok: boolean; error?: string }> {\n\t\ttry {\n\t\t\tawait dokployFetch<DokployProject[]>(target, \"project.all\");\n\t\t\treturn { ok: true };\n\t\t} catch (err) {\n\t\t\treturn { ok: false, error: err instanceof Error ? err.message : String(err) };\n\t\t}\n\t}\n\n\tasync deploy(input: DeployInput): Promise<DeployResult> {\n\t\tconst step1: DeployStep = { step: \"Create project\", status: \"pending\" };\n\t\tconst step2: DeployStep = { step: \"Create compose stack\", status: \"pending\" };\n\t\tconst step3: DeployStep = { step: \"Set environment variables\", status: \"pending\" };\n\t\tconst step4: DeployStep = { step: \"Trigger deployment\", status: \"pending\" };\n\t\tconst steps: DeployStep[] = [step1, step2, step3, step4];\n\n\t\tconst result: DeployResult = { success: false, steps };\n\n\t\ttry {\n\t\t\t// Step 1: Create project\n\t\t\tstep1.status = \"running\";\n\t\t\tconst project = await dokployFetch<DokployProject>(input.target, \"project.create\", {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: {\n\t\t\t\t\tname: input.projectName,\n\t\t\t\t\tdescription: input.description ?? `OpenClaw stack: ${input.projectName}`,\n\t\t\t\t},\n\t\t\t});\n\t\t\tresult.projectId = project.projectId;\n\t\t\tstep1.status = \"done\";\n\t\t\tstep1.detail = `Project ID: ${project.projectId}`;\n\n\t\t\t// Get the default environment ID\n\t\t\tconst projectDetail = await dokployFetch<DokployProject>(\n\t\t\t\tinput.target,\n\t\t\t\t`project.one?projectId=${project.projectId}`,\n\t\t\t);\n\t\t\tconst envId = projectDetail.environments?.[0]?.environmentId;\n\t\t\tif (!envId) {\n\t\t\t\tthrow new Error(\"No default environment found in project\");\n\t\t\t}\n\n\t\t\t// Step 2: Create compose stack\n\t\t\tstep2.status = \"running\";\n\t\t\tconst compose = await dokployFetch<DokployCompose>(input.target, \"compose.create\", {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: {\n\t\t\t\t\tname: input.projectName,\n\t\t\t\t\tenvironmentId: envId,\n\t\t\t\t\tcomposeFile: input.composeYaml,\n\t\t\t\t},\n\t\t\t});\n\t\t\tresult.composeId = compose.composeId;\n\t\t\tstep2.status = \"done\";\n\t\t\tstep2.detail = `Compose ID: ${compose.composeId}`;\n\n\t\t\t// Step 3: Set environment variables\n\t\t\tstep3.status = \"running\";\n\t\t\tawait dokployFetch(input.target, \"compose.update\", {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: {\n\t\t\t\t\tcomposeId: compose.composeId,\n\t\t\t\t\tenv: input.envContent,\n\t\t\t\t},\n\t\t\t});\n\t\t\tstep3.status = \"done\";\n\n\t\t\t// Step 4: Trigger deployment\n\t\t\tstep4.status = \"running\";\n\t\t\tawait dokployFetch(input.target, \"compose.deploy\", {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: {\n\t\t\t\t\tcomposeId: compose.composeId,\n\t\t\t\t\ttitle: `Initial deploy: ${input.projectName}`,\n\t\t\t\t\tdescription: input.description ?? \"Deployed via OpenClaw web builder\",\n\t\t\t\t},\n\t\t\t});\n\t\t\tstep4.status = \"done\";\n\n\t\t\tresult.success = true;\n\t\t\tconst base = input.target.instanceUrl.replace(/\\/+$/, \"\");\n\t\t\tresult.dashboardUrl = `${base}/dashboard/project/${project.projectId}`;\n\t\t} catch (err) {\n\t\t\tconst failedStep = steps.find((s) => s.status === \"running\");\n\t\t\tif (failedStep) {\n\t\t\t\tfailedStep.status = \"error\";\n\t\t\t\tfailedStep.detail = err instanceof Error ? err.message : String(err);\n\t\t\t}\n\t\t\tresult.error = err instanceof Error ? err.message : String(err);\n\t\t}\n\n\t\treturn result;\n\t}\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"dokploy.mjs","names":[],"sources":["../../src/deployers/dokploy.ts"],"sourcesContent":["/**\n * Dokploy PaaS deployer — deploys Docker Compose stacks via the Dokploy REST API.\n *\n * API docs: https://docs.dokploy.com/docs/api\n * Auth: x-api-key header\n * Endpoints use dot-notation (e.g. /api/project.create, /api/compose.deploy)\n */\n\nimport { sanitizeComposeForPaas } from \"./strip-host-ports.js\";\nimport type {\n\tDeployInput,\n\tDeployResult,\n\tDeployStep,\n\tDeployTarget,\n\tDokployEnvironment,\n\tPaasDeployer,\n\tPaasServer,\n} from \"./types.js\";\n\ninterface DokployProject {\n\tprojectId: string;\n\tname: string;\n\tdescription: string;\n\tenvironments?: DokployEnvironment[];\n}\n\ninterface DokployCompose {\n\tcomposeId: string;\n\tname: string;\n\tstatus?: string;\n\tcompose?: string;\n}\n\ninterface ProjectCreateResult {\n\tproject: DokployProject;\n\tprojectId: string;\n\tname: string;\n\tdescription: string;\n\tenvironments?: { environmentId: string; name: string }[];\n}\n\n/** Build a full Dokploy API URL from a dot-notation endpoint (e.g. \"project.create\"). */\nfunction apiUrl(target: DeployTarget, endpoint: string): string {\n\tconst base = target.instanceUrl.replace(/\\/+$/, \"\");\n\treturn `${base}/api/${endpoint}`;\n}\n/**\n * Typed fetch wrapper for the Dokploy API.\n * Handles JSON serialisation, x-api-key auth, and error extraction.\n */\nasync function dokployFetch<T>(\n\ttarget: DeployTarget,\n\tendpoint: string,\n\toptions: { method?: string; body?: unknown } = {},\n): Promise<T> {\n\tconst res = await fetch(apiUrl(target, endpoint), {\n\t\tmethod: options.method ?? \"GET\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\"x-api-key\": target.apiKey,\n\t\t},\n\t\tbody: options.body ? JSON.stringify(options.body) : undefined,\n\t});\n\n\tif (!res.ok) {\n\t\tconst text = await res.text().catch(() => \"\");\n\t\tlet detail = text;\n\n\t\ttry {\n\t\t\tconst json = JSON.parse(text);\n\t\t\tdetail = json.message || json.error || text;\n\t\t} catch {}\n\n\t\tthrow new Error(`Dokploy API ${res.status}: ${detail}`);\n\t}\n\n\tconst text = await res.text();\n\tif (!text) return undefined as T;\n\n\treturn JSON.parse(text) as T;\n}\n\n/**\n * Simple hash for compose diff detection\n */\nfunction hashString(str: string) {\n\tlet hash = 0;\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\thash = (hash << 5) - hash + str.charCodeAt(i);\n\t\thash |= 0;\n\t}\n\n\treturn hash;\n}\n\n/**\n * Deploys Docker Compose stacks to a Dokploy instance.\n *\n * Deploy flow (4 steps):\n * 1. Create a Dokploy project\n * 2. Create a compose stack inside the project's default environment\n * 3. Push .env variables to the compose stack\n * 4. Trigger the deployment\n */\n\nexport class DokployDeployer implements PaasDeployer {\n\treadonly name = \"Dokploy\";\n\treadonly id = \"dokploy\";\n\n\tasync testConnection(target: DeployTarget): Promise<{ ok: boolean; error?: string }> {\n\t\ttry {\n\t\t\tawait dokployFetch<DokployProject[]>(target, \"project.all\");\n\n\t\t\treturn { ok: true };\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t};\n\t\t}\n\t}\n\n\tasync listServers(target: DeployTarget): Promise<PaasServer[]> {\n\t\ttry {\n\t\t\tconst servers = await dokployFetch<{ serverId: string; name: string; ipAddress: string }[]>(\n\t\t\t\ttarget,\n\t\t\t\t\"server.all\",\n\t\t\t);\n\t\t\treturn servers.map((s) => ({\n\t\t\t\tid: s.serverId,\n\t\t\t\tname: s.name,\n\t\t\t\tip: s.ipAddress,\n\t\t\t}));\n\t\t} catch {\n\t\t\t// Return empty list if server API is not available\n\t\t\treturn [];\n\t\t}\n\t}\n\n\tasync deploy(input: DeployInput): Promise<DeployResult> {\n\t\tconst step1: DeployStep = {\n\t\t\tstep: \"Find or create project\",\n\t\t\tstatus: \"pending\",\n\t\t};\n\t\tconst step2: DeployStep = {\n\t\t\tstep: \"Find default environment\",\n\t\t\tstatus: \"pending\",\n\t\t};\n\t\tconst step3: DeployStep = {\n\t\t\tstep: \"Find or create compose stack\",\n\t\t\tstatus: \"pending\",\n\t\t};\n\t\tconst step4: DeployStep = {\n\t\t\tstep: \"Update stack configuration\",\n\t\t\tstatus: \"pending\",\n\t\t};\n\t\tconst step5: DeployStep = { step: \"Deploy stack\", status: \"pending\" };\n\t\tconst steps: DeployStep[] = [step1, step2, step3, step4, step5];\n\n\t\tconst result: DeployResult = { success: false, steps };\n\n\t\t// Strip host port bindings — Dokploy routes via Traefik,\n\t\t// so host ports are unnecessary and cause \"port already allocated\" errors.\n\t\tconst composeYaml = sanitizeComposeForPaas(input.composeYaml);\n\n\t\ttry {\n\t\t\t/**\n\t\t\t * STEP 1\n\t\t\t * Find or create project\n\t\t\t */\n\n\t\t\tstep1.status = \"running\";\n\n\t\t\tconst projects = await dokployFetch<DokployProject[]>(input.target, \"project.all\");\n\n\t\t\tlet project = projects.find((p) => p.name === input.projectName);\n\n\t\t\tif (!project) {\n\t\t\t\tconst created = await dokployFetch<ProjectCreateResult>(input.target, \"project.create\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tname: input.projectName,\n\t\t\t\t\t\tdescription: input.description ?? `OpenClaw stack: ${input.projectName}`,\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tproject = created.project;\n\t\t\t}\n\n\t\t\tresult.projectId = project.projectId;\n\n\t\t\tstep1.status = \"done\";\n\t\t\tstep1.detail = `Project ID: ${project.projectId}`;\n\n\t\t\t/**\n\t\t\t * STEP 2\n\t\t\t * Find default environment\n\t\t\t */\n\n\t\t\tstep2.status = \"running\";\n\n\t\t\tconst projectDetail = await dokployFetch<DokployProject>(\n\t\t\t\tinput.target,\n\t\t\t\t`project.one?projectId=${project.projectId}`,\n\t\t\t);\n\n\t\t\tconst env = projectDetail.environments?.find((e) => e.isDefault);\n\n\t\t\tif (!env) throw new Error(\"No default environment\");\n\n\t\t\tstep2.status = \"done\";\n\t\t\tstep2.detail = env.environmentId;\n\n\t\t\t/**\n\t\t\t * STEP 3\n\t\t\t * Find or create compose stack\n\t\t\t */\n\n\t\t\tstep3.status = \"running\";\n\n\t\t\tlet stack: DokployCompose | null = null;\n\n\t\t\tstack = await dokployFetch<DokployCompose>(input.target, \"compose.create\", {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: {\n\t\t\t\t\tname: input.projectName,\n\t\t\t\t\tdescription: input.description ?? `Stack ${input.projectName}`,\n\t\t\t\t\tenvironmentId: env.environmentId,\n\t\t\t\t\tcomposeType: \"docker-compose\",\n\t\t\t\t\tcomposeFile: composeYaml,\n\t\t\t\t\t...(input.serverId ? { serverId: input.serverId } : {}),\n\t\t\t\t},\n\t\t\t});\n\n\t\t\t// Dokploy's compose.create schema does NOT accept sourceType;\n\t\t\t// it defaults to \"github\". We must update it to \"raw\" so the\n\t\t\t// deploy step writes the compose file from the stored YAML\n\t\t\t// instead of attempting to clone from a Git provider.\n\t\t\tif (stack?.composeId) {\n\t\t\t\tawait dokployFetch(input.target, \"compose.update\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tcomposeId: stack.composeId,\n\t\t\t\t\t\tsourceType: \"raw\",\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tresult.composeId = stack?.composeId;\n\t\t\tstep3.status = \"done\";\n\t\t\tstep3.detail = stack?.composeId;\n\n\t\t\t/**\n\t\t\t * STEP 4\n\t\t\t * Update stack if compose changed\n\t\t\t */\n\n\t\t\tstep4.status = \"running\";\n\n\t\t\tconst existingStack = await dokployFetch<DokployCompose>(\n\t\t\t\tinput.target,\n\t\t\t\t`compose.one?composeId=${stack?.composeId}`,\n\t\t\t);\n\n\t\t\tconst newHash = hashString(composeYaml);\n\t\t\tconst oldHash = hashString(existingStack.compose ?? \"\");\n\n\t\t\tif (newHash !== oldHash) {\n\t\t\t\tawait dokployFetch(input.target, \"compose.update\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tcomposeId: stack?.composeId,\n\t\t\t\t\t\tcomposeFile: composeYaml,\n\t\t\t\t\t\tenv: input.envContent ?? \"\",\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tstep4.detail = \"Stack updated\";\n\t\t\t} else {\n\t\t\t\tstep4.detail = \"No compose changes\";\n\t\t\t}\n\n\t\t\tstep4.status = \"done\";\n\n\t\t\t/**\n\t\t\t * STEP 5\n\t\t\t * Deploy\n\t\t\t */\n\n\t\t\tstep5.status = \"running\";\n\n\t\t\tawait dokployFetch(input.target, \"compose.deploy\", {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: {\n\t\t\t\t\tcomposeId: stack?.composeId,\n\n\t\t\t\t\ttitle: `Deploy ${input.projectName}`,\n\n\t\t\t\t\tdescription: \"CI deployment\",\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tstep5.status = \"done\";\n\n\t\t\tresult.success = true;\n\n\t\t\tconst base = input.target.instanceUrl.replace(/\\/+$/, \"\");\n\n\t\t\tresult.dashboardUrl = `${base}/dashboard/project/${project.projectId}/environment/${env.environmentId}/services/compose/${stack?.composeId}?tab=deployments`;\n\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst running = steps.find((s) => s.status === \"running\");\n\n\t\t\tif (running) {\n\t\t\t\trunning.status = \"error\";\n\n\t\t\t\trunning.detail = err instanceof Error ? err.message : String(err);\n\t\t\t}\n\n\t\t\tresult.error = err instanceof Error ? err.message : String(err);\n\n\t\t\treturn result;\n\t\t}\n\t}\n}\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["DokployDeployer","CoolifyDeployer"],"sources":["../../src/deployers/index.ts"],"sourcesContent":["/**\n * PaaS deployer registry — barrel export + lookup helpers.\n *\n * To add a new provider, implement `PaasDeployer` and register it in\n * `deployerRegistry` below.\n */\n\nexport { CoolifyDeployer } from \"./coolify.js\";\nexport { DokployDeployer } from \"./dokploy.js\";\nexport type {\n\tDeployInput,\n\tDeployResult,\n\tDeployStep,\n\tDeployTarget,\n\tPaasDeployer,\n} from \"./types.js\";\n\nimport { CoolifyDeployer } from \"./coolify.js\";\nimport { DokployDeployer } from \"./dokploy.js\";\nimport type { PaasDeployer } from \"./types.js\";\n\n/** Registry of all available PaaS deployers. */\nexport const deployerRegistry: Record<string, PaasDeployer> = {\n\tdokploy: new DokployDeployer(),\n\tcoolify: new CoolifyDeployer(),\n};\n\n/** Get a deployer by ID, or undefined if not found. */\nexport function getDeployer(id: string): PaasDeployer | undefined {\n\treturn deployerRegistry[id];\n}\n\n/** List all available deployer IDs. */\nexport function getAvailableDeployers(): string[] {\n\treturn Object.keys(deployerRegistry);\n}\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["DokployDeployer","CoolifyDeployer"],"sources":["../../src/deployers/index.ts"],"sourcesContent":["/**\n * PaaS deployer registry — barrel export + lookup helpers.\n *\n * To add a new provider, implement `PaasDeployer` and register it in\n * `deployerRegistry` below.\n */\n\nexport { CoolifyDeployer } from \"./coolify.js\";\nexport { DokployDeployer } from \"./dokploy.js\";\nexport type {\n\tDeployInput,\n\tDeployResult,\n\tDeployStep,\n\tDeployTarget,\n\tPaasDeployer,\n\tPaasServer,\n} from \"./types.js\";\n\nimport { CoolifyDeployer } from \"./coolify.js\";\nimport { DokployDeployer } from \"./dokploy.js\";\nimport type { PaasDeployer } from \"./types.js\";\n\n/** Registry of all available PaaS deployers. */\nexport const deployerRegistry: Record<string, PaasDeployer> = {\n\tdokploy: new DokployDeployer(),\n\tcoolify: new CoolifyDeployer(),\n};\n\n/** Get a deployer by ID, or undefined if not found. */\nexport function getDeployer(id: string): PaasDeployer | undefined {\n\treturn deployerRegistry[id];\n}\n\n/** List all available deployer IDs. */\nexport function getAvailableDeployers(): string[] {\n\treturn Object.keys(deployerRegistry);\n}\n"],"mappings":";;;;;;AAuBA,MAAa,mBAAiD;CAC7D,SAAS,IAAIA,2CAAiB;CAC9B,SAAS,IAAIC,2CAAiB;CAC9B;;AAGD,SAAgB,YAAY,IAAsC;AACjE,QAAO,iBAAiB;;;AAIzB,SAAgB,wBAAkC;AACjD,QAAO,OAAO,KAAK,iBAAiB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeployInput, DeployResult, DeployStep, DeployTarget, PaasDeployer } from "./types.cjs";
|
|
1
|
+
import { DeployInput, DeployResult, DeployStep, DeployTarget, PaasDeployer, PaasServer } from "./types.cjs";
|
|
2
2
|
import { CoolifyDeployer } from "./coolify.cjs";
|
|
3
3
|
import { DokployDeployer } from "./dokploy.cjs";
|
|
4
4
|
|
|
@@ -10,5 +10,5 @@ declare function getDeployer(id: string): PaasDeployer | undefined;
|
|
|
10
10
|
/** List all available deployer IDs. */
|
|
11
11
|
declare function getAvailableDeployers(): string[];
|
|
12
12
|
//#endregion
|
|
13
|
-
export { CoolifyDeployer, type DeployInput, type DeployResult, type DeployStep, type DeployTarget, DokployDeployer, type PaasDeployer, deployerRegistry, getAvailableDeployers, getDeployer };
|
|
13
|
+
export { CoolifyDeployer, type DeployInput, type DeployResult, type DeployStep, type DeployTarget, DokployDeployer, type PaasDeployer, type PaasServer, deployerRegistry, getAvailableDeployers, getDeployer };
|
|
14
14
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/deployers/index.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/deployers/index.ts"],"mappings":";;;;;AA6BA;AAAA,cANa,gBAAA,EAAkB,MAAA,SAAe,YAAA;;iBAM9B,WAAA,CAAY,EAAA,WAAa,YAAA;;iBAKzB,qBAAA,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeployInput, DeployResult, DeployStep, DeployTarget, PaasDeployer } from "./types.mjs";
|
|
1
|
+
import { DeployInput, DeployResult, DeployStep, DeployTarget, PaasDeployer, PaasServer } from "./types.mjs";
|
|
2
2
|
import { CoolifyDeployer } from "./coolify.mjs";
|
|
3
3
|
import { DokployDeployer } from "./dokploy.mjs";
|
|
4
4
|
|
|
@@ -10,5 +10,5 @@ declare function getDeployer(id: string): PaasDeployer | undefined;
|
|
|
10
10
|
/** List all available deployer IDs. */
|
|
11
11
|
declare function getAvailableDeployers(): string[];
|
|
12
12
|
//#endregion
|
|
13
|
-
export { CoolifyDeployer, type DeployInput, type DeployResult, type DeployStep, type DeployTarget, DokployDeployer, type PaasDeployer, deployerRegistry, getAvailableDeployers, getDeployer };
|
|
13
|
+
export { CoolifyDeployer, type DeployInput, type DeployResult, type DeployStep, type DeployTarget, DokployDeployer, type PaasDeployer, type PaasServer, deployerRegistry, getAvailableDeployers, getDeployer };
|
|
14
14
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/deployers/index.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/deployers/index.ts"],"mappings":";;;;;AA6BA;AAAA,cANa,gBAAA,EAAkB,MAAA,SAAe,YAAA;;iBAM9B,WAAA,CAAY,EAAA,WAAa,YAAA;;iBAKzB,qBAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/deployers/index.ts"],"sourcesContent":["/**\n * PaaS deployer registry — barrel export + lookup helpers.\n *\n * To add a new provider, implement `PaasDeployer` and register it in\n * `deployerRegistry` below.\n */\n\nexport { CoolifyDeployer } from \"./coolify.js\";\nexport { DokployDeployer } from \"./dokploy.js\";\nexport type {\n\tDeployInput,\n\tDeployResult,\n\tDeployStep,\n\tDeployTarget,\n\tPaasDeployer,\n} from \"./types.js\";\n\nimport { CoolifyDeployer } from \"./coolify.js\";\nimport { DokployDeployer } from \"./dokploy.js\";\nimport type { PaasDeployer } from \"./types.js\";\n\n/** Registry of all available PaaS deployers. */\nexport const deployerRegistry: Record<string, PaasDeployer> = {\n\tdokploy: new DokployDeployer(),\n\tcoolify: new CoolifyDeployer(),\n};\n\n/** Get a deployer by ID, or undefined if not found. */\nexport function getDeployer(id: string): PaasDeployer | undefined {\n\treturn deployerRegistry[id];\n}\n\n/** List all available deployer IDs. */\nexport function getAvailableDeployers(): string[] {\n\treturn Object.keys(deployerRegistry);\n}\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/deployers/index.ts"],"sourcesContent":["/**\n * PaaS deployer registry — barrel export + lookup helpers.\n *\n * To add a new provider, implement `PaasDeployer` and register it in\n * `deployerRegistry` below.\n */\n\nexport { CoolifyDeployer } from \"./coolify.js\";\nexport { DokployDeployer } from \"./dokploy.js\";\nexport type {\n\tDeployInput,\n\tDeployResult,\n\tDeployStep,\n\tDeployTarget,\n\tPaasDeployer,\n\tPaasServer,\n} from \"./types.js\";\n\nimport { CoolifyDeployer } from \"./coolify.js\";\nimport { DokployDeployer } from \"./dokploy.js\";\nimport type { PaasDeployer } from \"./types.js\";\n\n/** Registry of all available PaaS deployers. */\nexport const deployerRegistry: Record<string, PaasDeployer> = {\n\tdokploy: new DokployDeployer(),\n\tcoolify: new CoolifyDeployer(),\n};\n\n/** Get a deployer by ID, or undefined if not found. */\nexport function getDeployer(id: string): PaasDeployer | undefined {\n\treturn deployerRegistry[id];\n}\n\n/** List all available deployer IDs. */\nexport function getAvailableDeployers(): string[] {\n\treturn Object.keys(deployerRegistry);\n}\n"],"mappings":";;;;;AAuBA,MAAa,mBAAiD;CAC7D,SAAS,IAAI,iBAAiB;CAC9B,SAAS,IAAI,iBAAiB;CAC9B;;AAGD,SAAgB,YAAY,IAAsC;AACjE,QAAO,iBAAiB;;;AAIzB,SAAgB,wBAAkC;AACjD,QAAO,OAAO,KAAK,iBAAiB"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_chunk = require('../chunk-C0xms8kb.cjs');
|
|
3
|
+
let yaml = require("yaml");
|
|
4
|
+
|
|
5
|
+
//#region src/deployers/strip-host-ports.ts
|
|
6
|
+
/**
|
|
7
|
+
* Strips host port bindings from a Docker Compose YAML string.
|
|
8
|
+
*
|
|
9
|
+
* When deploying to a PaaS like Dokploy or Coolify, services don't need
|
|
10
|
+
* host port mappings because routing is handled by the platform's built-in
|
|
11
|
+
* reverse proxy (Traefik). Binding to host ports causes "port already
|
|
12
|
+
* allocated" errors when ports are in use by other services on the server.
|
|
13
|
+
*
|
|
14
|
+
* Transforms port mappings:
|
|
15
|
+
* "8080:8080" → "8080" (container port only)
|
|
16
|
+
* "0.0.0.0:8080:80" → "80" (container port only)
|
|
17
|
+
* "8080:80/tcp" → "80/tcp" (preserves protocol)
|
|
18
|
+
* { published: 8080, target: 80 } → { target: 80 }
|
|
19
|
+
*
|
|
20
|
+
* The `expose` field is left untouched since it only defines internal ports.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Strips host port bindings from a Docker Compose YAML string,
|
|
24
|
+
* keeping only the container (target) ports.
|
|
25
|
+
*
|
|
26
|
+
* Returns the modified YAML string.
|
|
27
|
+
*/
|
|
28
|
+
function stripHostPorts(composeYaml) {
|
|
29
|
+
const doc = (0, yaml.parse)(composeYaml);
|
|
30
|
+
if (!doc?.services) return composeYaml;
|
|
31
|
+
for (const [, service] of Object.entries(doc.services)) {
|
|
32
|
+
if (!service.ports || !Array.isArray(service.ports)) continue;
|
|
33
|
+
service.ports = service.ports.map((port) => {
|
|
34
|
+
if (typeof port === "string") return stripStringPort(port);
|
|
35
|
+
if (typeof port === "object" && port !== null) return stripObjectPort(port);
|
|
36
|
+
return port;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return (0, yaml.stringify)(doc, { lineWidth: 200 });
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Strips host portion from a string port mapping.
|
|
43
|
+
*
|
|
44
|
+
* "8080:80" → "80"
|
|
45
|
+
* "0.0.0.0:8080:80" → "80"
|
|
46
|
+
* "80" → "80" (no change)
|
|
47
|
+
* "80/tcp" → "80/tcp"
|
|
48
|
+
* "8080:80/tcp" → "80/tcp"
|
|
49
|
+
*/
|
|
50
|
+
function stripStringPort(port) {
|
|
51
|
+
const protocolIdx = port.lastIndexOf("/");
|
|
52
|
+
let protocol = "";
|
|
53
|
+
let portSpec = port;
|
|
54
|
+
if (protocolIdx > 0) {
|
|
55
|
+
protocol = port.substring(protocolIdx);
|
|
56
|
+
portSpec = port.substring(0, protocolIdx);
|
|
57
|
+
}
|
|
58
|
+
const parts = portSpec.split(":");
|
|
59
|
+
return `${parts[parts.length - 1]}${protocol}`;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Strips host/published from an object port mapping.
|
|
63
|
+
*
|
|
64
|
+
* { target: 80, published: 8080 } → { target: 80 }
|
|
65
|
+
*/
|
|
66
|
+
function stripObjectPort(port) {
|
|
67
|
+
const { published: _, host_ip: __, ...rest } = port;
|
|
68
|
+
return rest;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Strips local bind mounts (paths starting with `./`) from a Docker
|
|
72
|
+
* Compose YAML string.
|
|
73
|
+
*
|
|
74
|
+
* When deploying to a PaaS like Dokploy or Coolify as a raw compose
|
|
75
|
+
* stack, there is no cloned repository — so host-relative volume mounts
|
|
76
|
+
* like `./postgres/init-databases.sh:/docker-entrypoint-initdb.d/...`
|
|
77
|
+
* will fail because the file doesn't exist on the remote server.
|
|
78
|
+
*
|
|
79
|
+
* Named volumes (e.g. `redis-data:/data`) and absolute system paths
|
|
80
|
+
* (e.g. `/var/run/docker.sock`) are kept intact.
|
|
81
|
+
*/
|
|
82
|
+
function stripLocalBindMounts(composeYaml) {
|
|
83
|
+
const doc = (0, yaml.parse)(composeYaml);
|
|
84
|
+
if (!doc?.services) return composeYaml;
|
|
85
|
+
for (const [, service] of Object.entries(doc.services)) {
|
|
86
|
+
if (!service.volumes || !Array.isArray(service.volumes)) continue;
|
|
87
|
+
service.volumes = service.volumes.filter((vol) => {
|
|
88
|
+
if (typeof vol === "string") return !vol.startsWith("./");
|
|
89
|
+
if (typeof vol === "object" && vol !== null) {
|
|
90
|
+
const src = vol.source;
|
|
91
|
+
return !(typeof src === "string" && src.startsWith("./"));
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
});
|
|
95
|
+
if (service.volumes.length === 0) delete service.volumes;
|
|
96
|
+
}
|
|
97
|
+
return (0, yaml.stringify)(doc, { lineWidth: 200 });
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Strips security hardening options (`cap_drop`, `cap_add`, `security_opt`)
|
|
101
|
+
* from all services in a Docker Compose YAML string.
|
|
102
|
+
*
|
|
103
|
+
* Many Docker images (PostgreSQL, Redis, MinIO, etc.) start as root and
|
|
104
|
+
* use `gosu`/`su-exec` to drop privileges to a non-root user. This
|
|
105
|
+
* requires `SETUID`, `SETGID`, and other capabilities. The hardened
|
|
106
|
+
* compose output adds `cap_drop: ALL` + `no-new-privileges`, which
|
|
107
|
+
* prevents this user switch and causes containers to crash with:
|
|
108
|
+
* "failed switching to 'postgres': operation not permitted"
|
|
109
|
+
*
|
|
110
|
+
* PaaS platforms (Dokploy, Coolify) manage their own container security,
|
|
111
|
+
* so these options are unnecessary and should be removed.
|
|
112
|
+
*/
|
|
113
|
+
function stripSecurityHardening(composeYaml) {
|
|
114
|
+
const doc = (0, yaml.parse)(composeYaml);
|
|
115
|
+
if (!doc?.services) return composeYaml;
|
|
116
|
+
for (const [, service] of Object.entries(doc.services)) {
|
|
117
|
+
delete service.cap_drop;
|
|
118
|
+
delete service.cap_add;
|
|
119
|
+
delete service.security_opt;
|
|
120
|
+
}
|
|
121
|
+
return (0, yaml.stringify)(doc, { lineWidth: 200 });
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Applies all PaaS-specific sanitisations to a Docker Compose YAML string:
|
|
125
|
+
* 1. Strips host port bindings (avoids "port already allocated" errors)
|
|
126
|
+
* 2. Strips local bind mounts (files don't exist on remote PaaS servers)
|
|
127
|
+
* 3. Strips security hardening (cap_drop/security_opt break user switching)
|
|
128
|
+
*/
|
|
129
|
+
function sanitizeComposeForPaas(composeYaml) {
|
|
130
|
+
return stripSecurityHardening(stripLocalBindMounts(stripHostPorts(composeYaml)));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
//#endregion
|
|
134
|
+
exports.sanitizeComposeForPaas = sanitizeComposeForPaas;
|
|
135
|
+
exports.stripHostPorts = stripHostPorts;
|
|
136
|
+
exports.stripLocalBindMounts = stripLocalBindMounts;
|
|
137
|
+
exports.stripSecurityHardening = stripSecurityHardening;
|
|
138
|
+
//# sourceMappingURL=strip-host-ports.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-host-ports.cjs","names":[],"sources":["../../src/deployers/strip-host-ports.ts"],"sourcesContent":["/**\n * Strips host port bindings from a Docker Compose YAML string.\n *\n * When deploying to a PaaS like Dokploy or Coolify, services don't need\n * host port mappings because routing is handled by the platform's built-in\n * reverse proxy (Traefik). Binding to host ports causes \"port already\n * allocated\" errors when ports are in use by other services on the server.\n *\n * Transforms port mappings:\n * \"8080:8080\" → \"8080\" (container port only)\n * \"0.0.0.0:8080:80\" → \"80\" (container port only)\n * \"8080:80/tcp\" → \"80/tcp\" (preserves protocol)\n * { published: 8080, target: 80 } → { target: 80 }\n *\n * The `expose` field is left untouched since it only defines internal ports.\n */\n\nimport { parse, stringify } from \"yaml\";\n\ninterface ComposeService {\n\tports?: (string | PortObject)[];\n\tvolumes?: (string | Record<string, unknown>)[];\n\t[key: string]: unknown;\n}\n\ninterface PortObject {\n\ttarget: number;\n\tpublished?: number | string;\n\thost_ip?: string;\n\tprotocol?: string;\n\t[key: string]: unknown;\n}\n\ninterface ComposeFile {\n\tservices?: Record<string, ComposeService>;\n\t[key: string]: unknown;\n}\n\n/**\n * Strips host port bindings from a Docker Compose YAML string,\n * keeping only the container (target) ports.\n *\n * Returns the modified YAML string.\n */\nexport function stripHostPorts(composeYaml: string): string {\n\tconst doc = parse(composeYaml) as ComposeFile;\n\n\tif (!doc?.services) return composeYaml;\n\n\tfor (const [, service] of Object.entries(doc.services)) {\n\t\tif (!service.ports || !Array.isArray(service.ports)) continue;\n\n\t\tservice.ports = service.ports.map((port) => {\n\t\t\tif (typeof port === \"string\") {\n\t\t\t\treturn stripStringPort(port);\n\t\t\t}\n\t\t\tif (typeof port === \"object\" && port !== null) {\n\t\t\t\treturn stripObjectPort(port);\n\t\t\t}\n\t\t\treturn port;\n\t\t});\n\t}\n\n\treturn stringify(doc, { lineWidth: 200 });\n}\n\n/**\n * Strips host portion from a string port mapping.\n *\n * \"8080:80\" → \"80\"\n * \"0.0.0.0:8080:80\" → \"80\"\n * \"80\" → \"80\" (no change)\n * \"80/tcp\" → \"80/tcp\"\n * \"8080:80/tcp\" → \"80/tcp\"\n */\nfunction stripStringPort(port: string): string {\n\t// Split off protocol if present (e.g. \"/tcp\", \"/udp\")\n\tconst protocolIdx = port.lastIndexOf(\"/\");\n\tlet protocol = \"\";\n\tlet portSpec = port;\n\n\tif (protocolIdx > 0) {\n\t\tprotocol = port.substring(protocolIdx); // includes the \"/\"\n\t\tportSpec = port.substring(0, protocolIdx);\n\t}\n\n\t// Split by \":\" — formats are:\n\t// \"80\" → container only\n\t// \"8080:80\" → host:container\n\t// \"0.0.0.0:8080:80\" → ip:host:container\n\tconst parts = portSpec.split(\":\");\n\n\t// Take the last part as the container port\n\tconst containerPort = parts[parts.length - 1];\n\n\treturn `${containerPort}${protocol}`;\n}\n\n/**\n * Strips host/published from an object port mapping.\n *\n * { target: 80, published: 8080 } → { target: 80 }\n */\nfunction stripObjectPort(port: PortObject): PortObject {\n\tconst { published: _, host_ip: __, ...rest } = port;\n\treturn rest;\n}\n\n/**\n * Strips local bind mounts (paths starting with `./`) from a Docker\n * Compose YAML string.\n *\n * When deploying to a PaaS like Dokploy or Coolify as a raw compose\n * stack, there is no cloned repository — so host-relative volume mounts\n * like `./postgres/init-databases.sh:/docker-entrypoint-initdb.d/...`\n * will fail because the file doesn't exist on the remote server.\n *\n * Named volumes (e.g. `redis-data:/data`) and absolute system paths\n * (e.g. `/var/run/docker.sock`) are kept intact.\n */\nexport function stripLocalBindMounts(composeYaml: string): string {\n\tconst doc = parse(composeYaml) as ComposeFile;\n\n\tif (!doc?.services) return composeYaml;\n\n\tfor (const [, service] of Object.entries(doc.services)) {\n\t\tif (!service.volumes || !Array.isArray(service.volumes)) continue;\n\n\t\tservice.volumes = (service.volumes as (string | Record<string, unknown>)[]).filter((vol) => {\n\t\t\tif (typeof vol === \"string\") {\n\t\t\t\t// Bind mounts starting with \"./\" reference local files\n\t\t\t\treturn !vol.startsWith(\"./\");\n\t\t\t}\n\t\t\t// Object-form: { type: \"bind\", source: \"./...\" }\n\t\t\tif (typeof vol === \"object\" && vol !== null) {\n\t\t\t\tconst src = (vol as Record<string, unknown>).source;\n\t\t\t\treturn !(typeof src === \"string\" && src.startsWith(\"./\"));\n\t\t\t}\n\t\t\treturn true;\n\t\t});\n\n\t\t// Remove empty volumes array to keep YAML clean\n\t\tif (service.volumes.length === 0) {\n\t\t\tdelete service.volumes;\n\t\t}\n\t}\n\n\treturn stringify(doc, { lineWidth: 200 });\n}\n\n/**\n * Strips security hardening options (`cap_drop`, `cap_add`, `security_opt`)\n * from all services in a Docker Compose YAML string.\n *\n * Many Docker images (PostgreSQL, Redis, MinIO, etc.) start as root and\n * use `gosu`/`su-exec` to drop privileges to a non-root user. This\n * requires `SETUID`, `SETGID`, and other capabilities. The hardened\n * compose output adds `cap_drop: ALL` + `no-new-privileges`, which\n * prevents this user switch and causes containers to crash with:\n * \"failed switching to 'postgres': operation not permitted\"\n *\n * PaaS platforms (Dokploy, Coolify) manage their own container security,\n * so these options are unnecessary and should be removed.\n */\nexport function stripSecurityHardening(composeYaml: string): string {\n\tconst doc = parse(composeYaml) as ComposeFile;\n\n\tif (!doc?.services) return composeYaml;\n\n\tfor (const [, service] of Object.entries(doc.services)) {\n\t\tdelete service.cap_drop;\n\t\tdelete service.cap_add;\n\t\tdelete service.security_opt;\n\t}\n\n\treturn stringify(doc, { lineWidth: 200 });\n}\n\n/**\n * Applies all PaaS-specific sanitisations to a Docker Compose YAML string:\n * 1. Strips host port bindings (avoids \"port already allocated\" errors)\n * 2. Strips local bind mounts (files don't exist on remote PaaS servers)\n * 3. Strips security hardening (cap_drop/security_opt break user switching)\n */\nexport function sanitizeComposeForPaas(composeYaml: string): string {\n\treturn stripSecurityHardening(stripLocalBindMounts(stripHostPorts(composeYaml)));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,SAAgB,eAAe,aAA6B;CAC3D,MAAM,sBAAY,YAAY;AAE9B,KAAI,CAAC,KAAK,SAAU,QAAO;AAE3B,MAAK,MAAM,GAAG,YAAY,OAAO,QAAQ,IAAI,SAAS,EAAE;AACvD,MAAI,CAAC,QAAQ,SAAS,CAAC,MAAM,QAAQ,QAAQ,MAAM,CAAE;AAErD,UAAQ,QAAQ,QAAQ,MAAM,KAAK,SAAS;AAC3C,OAAI,OAAO,SAAS,SACnB,QAAO,gBAAgB,KAAK;AAE7B,OAAI,OAAO,SAAS,YAAY,SAAS,KACxC,QAAO,gBAAgB,KAAK;AAE7B,UAAO;IACN;;AAGH,4BAAiB,KAAK,EAAE,WAAW,KAAK,CAAC;;;;;;;;;;;AAY1C,SAAS,gBAAgB,MAAsB;CAE9C,MAAM,cAAc,KAAK,YAAY,IAAI;CACzC,IAAI,WAAW;CACf,IAAI,WAAW;AAEf,KAAI,cAAc,GAAG;AACpB,aAAW,KAAK,UAAU,YAAY;AACtC,aAAW,KAAK,UAAU,GAAG,YAAY;;CAO1C,MAAM,QAAQ,SAAS,MAAM,IAAI;AAKjC,QAAO,GAFe,MAAM,MAAM,SAAS,KAEjB;;;;;;;AAQ3B,SAAS,gBAAgB,MAA8B;CACtD,MAAM,EAAE,WAAW,GAAG,SAAS,IAAI,GAAG,SAAS;AAC/C,QAAO;;;;;;;;;;;;;;AAeR,SAAgB,qBAAqB,aAA6B;CACjE,MAAM,sBAAY,YAAY;AAE9B,KAAI,CAAC,KAAK,SAAU,QAAO;AAE3B,MAAK,MAAM,GAAG,YAAY,OAAO,QAAQ,IAAI,SAAS,EAAE;AACvD,MAAI,CAAC,QAAQ,WAAW,CAAC,MAAM,QAAQ,QAAQ,QAAQ,CAAE;AAEzD,UAAQ,UAAW,QAAQ,QAAiD,QAAQ,QAAQ;AAC3F,OAAI,OAAO,QAAQ,SAElB,QAAO,CAAC,IAAI,WAAW,KAAK;AAG7B,OAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;IAC5C,MAAM,MAAO,IAAgC;AAC7C,WAAO,EAAE,OAAO,QAAQ,YAAY,IAAI,WAAW,KAAK;;AAEzD,UAAO;IACN;AAGF,MAAI,QAAQ,QAAQ,WAAW,EAC9B,QAAO,QAAQ;;AAIjB,4BAAiB,KAAK,EAAE,WAAW,KAAK,CAAC;;;;;;;;;;;;;;;;AAiB1C,SAAgB,uBAAuB,aAA6B;CACnE,MAAM,sBAAY,YAAY;AAE9B,KAAI,CAAC,KAAK,SAAU,QAAO;AAE3B,MAAK,MAAM,GAAG,YAAY,OAAO,QAAQ,IAAI,SAAS,EAAE;AACvD,SAAO,QAAQ;AACf,SAAO,QAAQ;AACf,SAAO,QAAQ;;AAGhB,4BAAiB,KAAK,EAAE,WAAW,KAAK,CAAC;;;;;;;;AAS1C,SAAgB,uBAAuB,aAA6B;AACnE,QAAO,uBAAuB,qBAAqB,eAAe,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//#region src/deployers/strip-host-ports.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Strips host port bindings from a Docker Compose YAML string.
|
|
4
|
+
*
|
|
5
|
+
* When deploying to a PaaS like Dokploy or Coolify, services don't need
|
|
6
|
+
* host port mappings because routing is handled by the platform's built-in
|
|
7
|
+
* reverse proxy (Traefik). Binding to host ports causes "port already
|
|
8
|
+
* allocated" errors when ports are in use by other services on the server.
|
|
9
|
+
*
|
|
10
|
+
* Transforms port mappings:
|
|
11
|
+
* "8080:8080" → "8080" (container port only)
|
|
12
|
+
* "0.0.0.0:8080:80" → "80" (container port only)
|
|
13
|
+
* "8080:80/tcp" → "80/tcp" (preserves protocol)
|
|
14
|
+
* { published: 8080, target: 80 } → { target: 80 }
|
|
15
|
+
*
|
|
16
|
+
* The `expose` field is left untouched since it only defines internal ports.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Strips host port bindings from a Docker Compose YAML string,
|
|
20
|
+
* keeping only the container (target) ports.
|
|
21
|
+
*
|
|
22
|
+
* Returns the modified YAML string.
|
|
23
|
+
*/
|
|
24
|
+
declare function stripHostPorts(composeYaml: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Strips local bind mounts (paths starting with `./`) from a Docker
|
|
27
|
+
* Compose YAML string.
|
|
28
|
+
*
|
|
29
|
+
* When deploying to a PaaS like Dokploy or Coolify as a raw compose
|
|
30
|
+
* stack, there is no cloned repository — so host-relative volume mounts
|
|
31
|
+
* like `./postgres/init-databases.sh:/docker-entrypoint-initdb.d/...`
|
|
32
|
+
* will fail because the file doesn't exist on the remote server.
|
|
33
|
+
*
|
|
34
|
+
* Named volumes (e.g. `redis-data:/data`) and absolute system paths
|
|
35
|
+
* (e.g. `/var/run/docker.sock`) are kept intact.
|
|
36
|
+
*/
|
|
37
|
+
declare function stripLocalBindMounts(composeYaml: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Strips security hardening options (`cap_drop`, `cap_add`, `security_opt`)
|
|
40
|
+
* from all services in a Docker Compose YAML string.
|
|
41
|
+
*
|
|
42
|
+
* Many Docker images (PostgreSQL, Redis, MinIO, etc.) start as root and
|
|
43
|
+
* use `gosu`/`su-exec` to drop privileges to a non-root user. This
|
|
44
|
+
* requires `SETUID`, `SETGID`, and other capabilities. The hardened
|
|
45
|
+
* compose output adds `cap_drop: ALL` + `no-new-privileges`, which
|
|
46
|
+
* prevents this user switch and causes containers to crash with:
|
|
47
|
+
* "failed switching to 'postgres': operation not permitted"
|
|
48
|
+
*
|
|
49
|
+
* PaaS platforms (Dokploy, Coolify) manage their own container security,
|
|
50
|
+
* so these options are unnecessary and should be removed.
|
|
51
|
+
*/
|
|
52
|
+
declare function stripSecurityHardening(composeYaml: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Applies all PaaS-specific sanitisations to a Docker Compose YAML string:
|
|
55
|
+
* 1. Strips host port bindings (avoids "port already allocated" errors)
|
|
56
|
+
* 2. Strips local bind mounts (files don't exist on remote PaaS servers)
|
|
57
|
+
* 3. Strips security hardening (cap_drop/security_opt break user switching)
|
|
58
|
+
*/
|
|
59
|
+
declare function sanitizeComposeForPaas(composeYaml: string): string;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { sanitizeComposeForPaas, stripHostPorts, stripLocalBindMounts, stripSecurityHardening };
|
|
62
|
+
//# sourceMappingURL=strip-host-ports.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-host-ports.d.cts","names":[],"sources":["../../src/deployers/strip-host-ports.ts"],"mappings":";;AA4CA;;;;;AA4EA;;;;;AA4CA;;;;;AAoBA;;;;;;AAAA,iBA5IgB,cAAA,CAAe,WAAA;;;;;;;;;;;;;iBA4Ef,oBAAA,CAAqB,WAAA;;;;;;;;;;;;;;;iBA4CrB,sBAAA,CAAuB,WAAA;;;;;;;iBAoBvB,sBAAA,CAAuB,WAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//#region src/deployers/strip-host-ports.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Strips host port bindings from a Docker Compose YAML string.
|
|
4
|
+
*
|
|
5
|
+
* When deploying to a PaaS like Dokploy or Coolify, services don't need
|
|
6
|
+
* host port mappings because routing is handled by the platform's built-in
|
|
7
|
+
* reverse proxy (Traefik). Binding to host ports causes "port already
|
|
8
|
+
* allocated" errors when ports are in use by other services on the server.
|
|
9
|
+
*
|
|
10
|
+
* Transforms port mappings:
|
|
11
|
+
* "8080:8080" → "8080" (container port only)
|
|
12
|
+
* "0.0.0.0:8080:80" → "80" (container port only)
|
|
13
|
+
* "8080:80/tcp" → "80/tcp" (preserves protocol)
|
|
14
|
+
* { published: 8080, target: 80 } → { target: 80 }
|
|
15
|
+
*
|
|
16
|
+
* The `expose` field is left untouched since it only defines internal ports.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Strips host port bindings from a Docker Compose YAML string,
|
|
20
|
+
* keeping only the container (target) ports.
|
|
21
|
+
*
|
|
22
|
+
* Returns the modified YAML string.
|
|
23
|
+
*/
|
|
24
|
+
declare function stripHostPorts(composeYaml: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Strips local bind mounts (paths starting with `./`) from a Docker
|
|
27
|
+
* Compose YAML string.
|
|
28
|
+
*
|
|
29
|
+
* When deploying to a PaaS like Dokploy or Coolify as a raw compose
|
|
30
|
+
* stack, there is no cloned repository — so host-relative volume mounts
|
|
31
|
+
* like `./postgres/init-databases.sh:/docker-entrypoint-initdb.d/...`
|
|
32
|
+
* will fail because the file doesn't exist on the remote server.
|
|
33
|
+
*
|
|
34
|
+
* Named volumes (e.g. `redis-data:/data`) and absolute system paths
|
|
35
|
+
* (e.g. `/var/run/docker.sock`) are kept intact.
|
|
36
|
+
*/
|
|
37
|
+
declare function stripLocalBindMounts(composeYaml: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Strips security hardening options (`cap_drop`, `cap_add`, `security_opt`)
|
|
40
|
+
* from all services in a Docker Compose YAML string.
|
|
41
|
+
*
|
|
42
|
+
* Many Docker images (PostgreSQL, Redis, MinIO, etc.) start as root and
|
|
43
|
+
* use `gosu`/`su-exec` to drop privileges to a non-root user. This
|
|
44
|
+
* requires `SETUID`, `SETGID`, and other capabilities. The hardened
|
|
45
|
+
* compose output adds `cap_drop: ALL` + `no-new-privileges`, which
|
|
46
|
+
* prevents this user switch and causes containers to crash with:
|
|
47
|
+
* "failed switching to 'postgres': operation not permitted"
|
|
48
|
+
*
|
|
49
|
+
* PaaS platforms (Dokploy, Coolify) manage their own container security,
|
|
50
|
+
* so these options are unnecessary and should be removed.
|
|
51
|
+
*/
|
|
52
|
+
declare function stripSecurityHardening(composeYaml: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Applies all PaaS-specific sanitisations to a Docker Compose YAML string:
|
|
55
|
+
* 1. Strips host port bindings (avoids "port already allocated" errors)
|
|
56
|
+
* 2. Strips local bind mounts (files don't exist on remote PaaS servers)
|
|
57
|
+
* 3. Strips security hardening (cap_drop/security_opt break user switching)
|
|
58
|
+
*/
|
|
59
|
+
declare function sanitizeComposeForPaas(composeYaml: string): string;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { sanitizeComposeForPaas, stripHostPorts, stripLocalBindMounts, stripSecurityHardening };
|
|
62
|
+
//# sourceMappingURL=strip-host-ports.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-host-ports.d.mts","names":[],"sources":["../../src/deployers/strip-host-ports.ts"],"mappings":";;AA4CA;;;;;AA4EA;;;;;AA4CA;;;;;AAoBA;;;;;;AAAA,iBA5IgB,cAAA,CAAe,WAAA;;;;;;;;;;;;;iBA4Ef,oBAAA,CAAqB,WAAA;;;;;;;;;;;;;;;iBA4CrB,sBAAA,CAAuB,WAAA;;;;;;;iBAoBvB,sBAAA,CAAuB,WAAA"}
|