Skip to content

fix(compose): preserve env interpolation references - #5158

Open
mameikagou wants to merge 1 commit into
Dokploy:canaryfrom
mameikagou:codex/fix-compose-env-interpolation
Open

fix(compose): preserve env interpolation references#5158
mameikagou wants to merge 1 commit into
Dokploy:canaryfrom
mameikagou:codex/fix-compose-env-interpolation

Conversation

@mameikagou

@mameikagou mameikagou commented Aug 22, 2026

Copy link
Copy Markdown

What is this PR about?

Preserve valid Docker Compose ${VAR} and $VAR references when writing deployment environment files, while continuing to escape literal dollar signs such as pa$$word. Regression coverage checks both forms through the existing environment-file path.

Checklist

  • Created a dedicated branch based on canary.
  • Read the pull request guidance in CONTRIBUTING.md.
  • Tested the change locally.

Issues related

Closes #5151

Validation

  • Focused Vitest regression
  • Docker Compose config interpolation check
  • Dokploy and server TypeScript checks
  • Biome and git diff --check

Greptile Summary

This PR selectively preserves Docker Compose $VAR and ${VAR} interpolation references while continuing to escape literal dollar signs, with focused unit and Compose integration coverage.

  • Replaces unconditional dollar escaping with Compose-reference detection.
  • Adds regression coverage for braced and unbraced interpolation alongside literal double-dollar values.

Confidence Score: 4/5

This PR should not merge until resolved project, environment, and service-placeholder values are prevented from being reinterpreted as Docker Compose references.

The new classifier runs after Dokploy placeholder substitution, so literal dollar sequences inside resolved secrets or configuration values can be expanded or erased by Docker Compose.

Files Needing Attention: packages/server/src/utils/docker/utils.ts

Reviews (1): Last reviewed commit: "fix(compose): preserve env interpolation..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Context used:

@mameikagou
mameikagou marked this pull request as ready for review August 22, 2026 02:14
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Aug 22, 2026
Comment on lines +553 to +559
const isVariableReference =
source[offset - 1] !== "$" &&
(/^\{[A-Za-z_][A-Za-z0-9_]*(?:(?::[-+?]|[-+?])[^}]*)?\}/.test(
suffix,
) ||
/^[A-Za-z_][A-Za-z0-9_]*/.test(suffix));
return isVariableReference ? match : `\\${match}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Resolved values become references

When a project, environment, or service placeholder resolves to a literal value containing $VAR or ${VAR}, this classifier preserves that sequence as active Compose interpolation, causing Docker Compose to expand or erase part of the deployed secret or configuration value.

Knowledge Base Used: Application Deployment Flow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

${VAR} self-reference in .env values no longer interpolates — prepareEnvironmentVariablesForFile escapes every $, including inside ${VAR}

1 participant