Skip to content

fix: pass --env-file so the generated .env is found with --project-directory - #5235

Open
tonnenpinguin wants to merge 1 commit into
Dokploy:canaryfrom
tonnenpinguin:fix/compose-env-file-project-directory
Open

fix: pass --env-file so the generated .env is found with --project-directory#5235
tonnenpinguin wants to merge 1 commit into
Dokploy:canaryfrom
tonnenpinguin:fix/compose-env-file-project-directory

Conversation

@tonnenpinguin

@tonnenpinguin tonnenpinguin commented Aug 31, 2026

Copy link
Copy Markdown

What is this PR about?

Since 87b9149, compose deploys run with --project-directory <code>, so docker compose looks for .env in the code root — but getCreateEnvFileCommand writes the Environment-tab .env next to the compose file. For nested compose paths (e.g. ./docker/docker-compose.yml) every ${VAR} silently interpolates to a blank string:

The "INFLUXDB_INIT_ADMIN_TOKEN" variable is not set. Defaulting to a blank string.

Fix: createCommand passes --env-file <dirname(composePath)>/.env (only when Create Environment File is enabled; docker-compose type only — stack already uses env export).

Checklist

  • You created a dedicated branch based on the canary branch.
  • You have read the suggestions in the CONTRIBUTING.md file https://github.com/Dokploy/dokploy/blob/canary/CONTRIBUTING.md#pull-request
  • You have tested this PR in your local instance. If you have not tested it yet, please do so before submitting. This helps avoid wasting maintainers' time reviewing code that has not been verified by you.

Tested via:

  • 4 new unit tests in compose-project-directory.test.ts (nested path, disabled flag, raw, stack); full compose suite passes except the pre-existing docker-dependent env-file-literals integration test
  • Full local dev instance (pnpm dokploy:dev, v0.30.3 canary): custom-git compose app with composePath: ./docker/docker-compose.yml, Environment-tab var, Create Environment File on
    • unpatched: The "TESTVAR" variable is not set. Defaulting to a blank string., container env empty
    • patched: command gains --env-file docker/.env, no warning, container receives the value

Issues related (if applicable)

Same root cause as #5230 (different symptom: that one is build.context, this one is .env interpolation). Hit in production upgrading v0.30.2 → v0.30.3.

The .env from the Environment tab is written next to the compose file
(getCreateEnvFileCommand), but --project-directory (added in 87b9149)
makes docker compose look for .env in the project directory instead.
For nested compose paths every ${VAR} silently interpolates to a blank
string. Point compose at the generated file explicitly.

Related: Dokploy#5230
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant