Summary
Compose import now reads each service's env_file: — string, list, and long-form {path, required, format} entries — resolves the paths against the compose file's directory, and merges the referenced dotenv/raw contents into the service environment below environment:, matching Compose's own precedence. Files that cannot be read surface as a non-blocking unsupported warning instead of vanishing silently.
Motivation
#1854: a service's env_file: was dropped in silence. parseComposeFile never read svc.env_file, and UNSUPPORTED_SERVICE_KEYS had no entry for it, so collectUnsupported stayed quiet — the exact failure mode #533 set out to prevent. The app then starts without DATABASE_URL, SECRET_KEY_BASE, etc., and nothing points at env_file as the reason. The issue sketches two directions (a minimal UNSUPPORTED_SERVICE_KEYS warning vs. actually reading the files); this implements the fuller one — the values arrive, and unreadable files still get the honest warning, so both failure modes are covered.
Verified still present on current main (e94cbb99b): env_file is absent from the parser and from UNSUPPORTED_SERVICE_KEYS (only envFileContent interpolation of the compose-adjacent .env exists).
Related issue
Fixes #1854.
Changes
packages/platformcompose-parser.ts:parseServiceEnvFiles+resolveServiceEnvFiles— normalizeenv_filedeclarations, interpolate the path, resolve it againstcomposeDirectory(the compose file's directory, like Compose itself), and parse contents as dotenv (default) or literalKEY=VALUElines (format: raw).- Values merge below
environment:— later files override earlier ones, explicitenvironment:values win. - A file that cannot be read lands on
unsupportedas a non-blocking warning naming the service and path;required: falseentries stay silent, matching Compose. Absolute/~/..-above-root paths and malformed entries are reported rather than dropped. composeEnvFilePaths— exported helper returning the resolved repo-relative paths a compose file names, so callers know exactly what to fetch.ComposeParseOptionsgainscomposeDirectoryandenvFileContents;hasEnvironmentDeclarationnow also countsenv_fileso snapshot-safe sync paths treat the merged env correctly.
packages/platformprepare.service.ts:readComposeEnvFileContentsfetches each declared path through the sameProjectReaderused for the compose file (local and Git-backed sources behave identically);resolveFromReaderpasses the map intotoProjectInfo→parseComposeFile.- Callers that parse without a reader (migration, docker-inspect) still get the
unsupportedwarning rather than silence.
- Tests:
apps/api/test/lib/compose-parser.test.ts— 10 cases: merge order andenvironment:precedence,composeDirectoryresolution, later-file override,required: falseopt-out, unreadable-file warning (non-blocking), no-reader warning, out-of-repo paths, path interpolation, dotenv-vs-rawformat, and literal-value handling.apps/api/test/modules/deployments/prepare.service.test.ts— end-to-end throughresolveProjectInfoon a real temp tree:deploy/api.envis read relative todeploy/docker-compose.yaml,environment:still wins, and the missing./missing.envis reported.
Verification
$ cd apps/api && bunx vitest run test/lib/compose-parser.test.ts test/modules/deployments/prepare.service.test.ts
Test Files 2 passed (2)
Tests 236 passed (236)
$ cd packages/platform && bunx tsc --noEmit # clean
$ cd apps/api && bunx tsc --noEmit # clean (lint script)
$ cd packages/platform && bunx vitest run src/engine/modules/deployments/compose-review.test.ts src/engine/modules/deployments/compose/build-service-dns.test.ts
Tests 22 passed (22)Sabotage check (RED): with compose-parser.ts + prepare.service.ts reverted to upstream/main, all 10 new env_file parser tests fail (e.g. environment stays {}, no env_file warning); restoring the fix turns them green.
bunx prettier agrees with every line this PR adds. Several touched files already fail prettier --check on upstream main (pre-existing drift), so bun format was not run over them — the diff is kept byte-scoped with no unrelated reformatting.
Screenshots
N/A — parser/import-path change, no UI surface.
Checklist
- One change per PR — one bug, or one agreed feature, with nothing unrelated bundled in
- The diff is scoped — no reformatting or lint fixes on lines I wasn't otherwise changing
- A test fails without this change and passes with it (or I explained above why there isn't one)
- Relevant test suites, typechecks, and changed-line formatting pass locally
- I understand every line of this diff and can explain it in review