mirror of
https://github.com/andwati/dokploy.git
synced 2026-10-31 17:22:16 +00:00
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 #4794 Co-Authored-By: Codex <[email protected]>
This commit is contained in:
@@ -0,0 +1,59 @@
|
|||||||
|
import { addDomainToCompose } from "@dokploy/server/utils/docker/domain";
|
||||||
|
import { execAsyncRemote } from "@dokploy/server/utils/process/execAsync";
|
||||||
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
|
vi.mock("@dokploy/server/utils/process/execAsync", async (importOriginal) => ({
|
||||||
|
...(await importOriginal<
|
||||||
|
typeof import("@dokploy/server/utils/process/execAsync")
|
||||||
|
>()),
|
||||||
|
execAsyncRemote: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe("raw remote compose conversion (#4794)", () => {
|
||||||
|
it("uses the saved raw source and preserves supported mount syntax", async () => {
|
||||||
|
vi.mocked(execAsyncRemote).mockResolvedValue({
|
||||||
|
stdout: "services:\n test:\n image: alpine:latest\n",
|
||||||
|
stderr: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
const compose = {
|
||||||
|
appName: "raw-stack",
|
||||||
|
composeFile: `
|
||||||
|
services:
|
||||||
|
test:
|
||||||
|
image: alpine:latest
|
||||||
|
volumes:
|
||||||
|
- type: tmpfs
|
||||||
|
target: /scratch
|
||||||
|
- type: volume
|
||||||
|
source: test-data
|
||||||
|
target: /data
|
||||||
|
tmpfs:
|
||||||
|
- /cache
|
||||||
|
volumes:
|
||||||
|
test-data:
|
||||||
|
`,
|
||||||
|
composePath: "./docker-compose.yml",
|
||||||
|
composeType: "stack",
|
||||||
|
isolatedDeployment: false,
|
||||||
|
isolatedDeploymentsVolume: false,
|
||||||
|
randomize: false,
|
||||||
|
serverId: "remote-server",
|
||||||
|
sourceType: "raw",
|
||||||
|
suffix: "",
|
||||||
|
} as unknown as Parameters<typeof addDomainToCompose>[0];
|
||||||
|
|
||||||
|
const converted = await addDomainToCompose(compose, []);
|
||||||
|
|
||||||
|
expect(converted?.services?.test?.volumes).toEqual([
|
||||||
|
{ type: "tmpfs", target: "/scratch" },
|
||||||
|
{
|
||||||
|
type: "volume",
|
||||||
|
source: "test-data",
|
||||||
|
target: "/data",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
expect(converted?.services?.test?.tmpfs).toEqual(["/cache"]);
|
||||||
|
expect(execAsyncRemote).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -139,7 +139,11 @@ export const addDomainToCompose = async (
|
|||||||
|
|
||||||
let result: ComposeSpecification | null;
|
let result: ComposeSpecification | null;
|
||||||
|
|
||||||
if (compose.serverId) {
|
if (compose.sourceType === "raw") {
|
||||||
|
result = parse(compose.composeFile, {
|
||||||
|
maxAliasCount: 10000,
|
||||||
|
}) as ComposeSpecification;
|
||||||
|
} else if (compose.serverId) {
|
||||||
result = await loadDockerComposeRemote(compose);
|
result = await loadDockerComposeRemote(compose);
|
||||||
} else {
|
} else {
|
||||||
result = await loadDockerCompose(compose);
|
result = await loadDockerCompose(compose);
|
||||||
|
|||||||
Reference in New Issue
Block a user