Skip to content

fix: add createEnvFile toggle to Compose, mirroring Application - #5008

Merged
Siumauricio merged 2 commits into
canaryfrom
fix/compose-create-env-file-toggle
Aug 8, 2026
Merged

fix: add createEnvFile toggle to Compose, mirroring Application#5008
Siumauricio merged 2 commits into
canaryfrom
fix/compose-create-env-file-toggle

Conversation

@narcisonunez

@narcisonunez narcisonunez commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

What is this PR about?

Compose always overwrote .env on every deploy, even when a repo already committed its own. Add the same createEnvFile switch Application has (default true) so users can opt out and Dokploy leaves the file alone.

Adds the same createEnvFile toggle Application already has (default true, same UI copy/pattern). When disabled, Dokploy never touches .env, so a repo-tracked file survives untouched.

Checklist

Before submitting this PR, please make sure that:

  • 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.

Issues related (if applicable)

closes #4956

Screenshots (if applicable)

Greptile Summary

The PR adds a persisted createEnvFile setting for Compose projects and exposes it through the environment editor and deployment builder.

  • Adds the Compose schema column and migration with a default of true.
  • Allows the environment mutation and dashboard form to update the setting.
  • Skips generating .env during Compose deployment when the setting is disabled.
  • Adds focused command-generation tests for enabled and disabled states.

Confidence Score: 4/5

The PR is not yet safe to merge because disabling createEnvFile during a git-based rebuild can leave Docker Compose consuming a stale generated .env.

The builder only stops writing .env; it does not remove an existing generated file, while non-raw rebuilds reuse the checkout and invoke Docker Compose from that directory.

Files Needing Attention: packages/server/src/utils/builders/compose.ts

Reviews (2): Last reviewed commit: "[autofix.ci] apply automated fixes" | Re-trigger Greptile

Context used:

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 7, 2026
Comment on lines +22 to +24
const envCommand = compose.createEnvFile
? getCreateEnvFileCommand(compose)
: "";

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 Stale generated env survives rebuilds

When a non-raw Compose project is deployed with createEnvFile enabled and the setting is later disabled, rebuildCompose reuses the checkout while this branch neither rewrites nor removes the generated .env. Docker Compose then reads the stale file and deploys with obsolete project and environment values despite the toggle being disabled.

Knowledge Base Used: Compose Deployment Flow

@narcisonunez
narcisonunez force-pushed the fix/compose-create-env-file-toggle branch from 965d5f0 to be71866 Compare August 7, 2026 21:52
@Siumauricio
Siumauricio merged commit c05511d into canary Aug 8, 2026
5 checks passed
@Siumauricio
Siumauricio deleted the fix/compose-create-env-file-toggle branch August 8, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compose builder truncates a repo-tracked .env, even with an empty Environment tab

2 participants