Skip to content

Commit b67519e

Browse files
committed
fix: preserve parameter expansion (${VAR:-default}) in .env interpolation
1 parent 452b7aa commit b67519e

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎apps/dokploy/__test__/compose/env-file-literals.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const cases: Record<string, string> = {
3434
MULTILINE_PEM: "-----BEGIN KEY-----\nabc123\n-----END KEY-----",
3535
APP_URL: "https://example.com",
3636
ASSET_URL: "https://example.com",
37+
DB_HOST: "localhost",
3738
};
3839

3940
// How each value must be typed in the UI so the (unchanged) dotenv input
@@ -50,6 +51,7 @@ const inputEncoding: Record<string, string> = {
5051
MULTILINE_PEM: '"-----BEGIN KEY-----\nabc123\n-----END KEY-----"',
5152
APP_URL: "https://example.com",
5253
ASSET_URL: '"${APP_URL}"',
54+
DB_HOST: '"${UNDEFINED_HOST:-localhost}"',
5355
};
5456

5557
describe("getCreateEnvFileCommand", () => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ export const prepareEnvironmentVariablesForFile = (
548548
const escapedValue = value
549549
.replace(/\\/g, "\\\\")
550550
.replace(/"/g, '\\"')
551-
.replace(/\$(?!\{[A-Za-z_][A-Za-z0-9_]*\})/g, "\\$");
551+
.replace(/\$(?!\{[A-Za-z_][A-Za-z0-9_]*(?::?[-+?][^{}]*)?\})/g, "\\$");
552552
return `${key}="${escapedValue}"`;
553553
});
554554
};

0 commit comments

Comments
 (0)