Skip to content

Commit e43d99e

Browse files
yusoofshcodex
andcommitted
fix(compose): Preserve raw remote mounts
Use the saved raw compose source during conversion instead of reading a potentially stale remote materialization. Preserve tmpfs declarations and long-syntax volume mounts through preview and stack deployment. Fixes Dokploy#4794 Co-Authored-By: Codex <[email protected]>
1 parent 1c44141 commit e43d99e

2 files changed

Lines changed: 64 additions & 1 deletion

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { addDomainToCompose } from "@dokploy/server/utils/docker/domain";
2+
import { execAsyncRemote } from "@dokploy/server/utils/process/execAsync";
3+
import { describe, expect, it, vi } from "vitest";
4+
5+
vi.mock("@dokploy/server/utils/process/execAsync", async (importOriginal) => ({
6+
...(await importOriginal<
7+
typeof import("@dokploy/server/utils/process/execAsync")
8+
>()),
9+
execAsyncRemote: vi.fn(),
10+
}));
11+
12+
describe("raw remote compose conversion (#4794)", () => {
13+
it("uses the saved raw source and preserves supported mount syntax", async () => {
14+
vi.mocked(execAsyncRemote).mockResolvedValue({
15+
stdout: "services:\n test:\n image: alpine:latest\n",
16+
stderr: "",
17+
});
18+
19+
const compose = {
20+
appName: "raw-stack",
21+
composeFile: `
22+
services:
23+
test:
24+
image: alpine:latest
25+
volumes:
26+
- type: tmpfs
27+
target: /scratch
28+
- type: volume
29+
source: test-data
30+
target: /data
31+
tmpfs:
32+
- /cache
33+
volumes:
34+
test-data:
35+
`,
36+
composePath: "./docker-compose.yml",
37+
composeType: "stack",
38+
isolatedDeployment: false,
39+
isolatedDeploymentsVolume: false,
40+
randomize: false,
41+
serverId: "remote-server",
42+
sourceType: "raw",
43+
suffix: "",
44+
} as unknown as Parameters<typeof addDomainToCompose>[0];
45+
46+
const converted = await addDomainToCompose(compose, []);
47+
48+
expect(converted?.services?.test?.volumes).toEqual([
49+
{ type: "tmpfs", target: "/scratch" },
50+
{
51+
type: "volume",
52+
source: "test-data",
53+
target: "/data",
54+
},
55+
]);
56+
expect(converted?.services?.test?.tmpfs).toEqual(["/cache"]);
57+
expect(execAsyncRemote).not.toHaveBeenCalled();
58+
});
59+
});

‎packages/server/src/utils/docker/domain.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ export const addDomainToCompose = async (
139139

140140
let result: ComposeSpecification | null;
141141

142-
if (compose.serverId) {
142+
if (compose.sourceType === "raw") {
143+
result = parse(compose.composeFile, {
144+
maxAliasCount: 10000,
145+
}) as ComposeSpecification;
146+
} else if (compose.serverId) {
143147
result = await loadDockerComposeRemote(compose);
144148
} else {
145149
result = await loadDockerCompose(compose);

0 commit comments

Comments
 (0)