#1854

Compose import silently ignores a service's env_file

Openshani-singh1opened 14d ago

Existing issue

  • I have searched the existing issues and found no duplicate.

Problem description

A Compose import ignores a service's env_file:. The variables in that file never reach the container, and the import reports nothing about it.

parseComposeFile (packages/platform/src/engine/lib/compose-parser.ts) never reads svc.env_file. UNSUPPORTED_SERVICE_KEYS has no entry for it either, so collectUnsupported stays silent. That goes against the parser's own rule that a dropped key must not be invisible (#533). Nothing else on the API import path (prepare.service.ts → toProjectInfo → parseComposeFile) fetches the referenced files. Only the .env next to the compose file is read, for interpolation and the opt-in rootEnv rows.

So a common layout deploys with missing configuration:

services:
  web:
    image: nginx:1.27
    env_file: ./config/app.env

The app starts without DATABASE_URL, SECRET_KEY_BASE and so on, and nothing points at env_file as the reason.

The CLI path already behaves differently. openship service sync resolves the file with docker compose config, so the SDK mapper receives the merged environment. The same compose file therefore produces different services depending on whether it is imported from the dashboard or synced from the CLI.

Steps to reproduce

  1. Create a repo with this compose.yml:

    services:
      web:
        image: nginx:1.27
        env_file: ./config/app.env
      api:
        image: node:22
        environment:
          PORT: "3000"
        env_file:
          - path: ./api.env
            required: false

    and config/app.env:

    DATABASE_URL=postgres://db/app
    SECRET_KEY_BASE=abc
  2. Import it as a Compose project, or call parseComposeFile directly.

Result on main (d60e23fef), from parseComposeFile:

web  environment= {}
api  environment= {"PORT":"3000"}
unsupported= []

Expected, from Docker Compose for the same files (docker compose config --format json, v5.1.4):

web  environment= {"DATABASE_URL":"postgres://db/app","SECRET_KEY_BASE":"abc"}
api  environment= {"PORT":"3000"}      # api.env is absent and required: false, so it is skipped

Environment

  • Openship main at d60e23fef (self-hosted, Compose import from a Git repo)
  • Docker Compose v5.1.4 used for the expected output

Additional context

There are two possible directions, and I'd like a maintainer to pick one before I write a PR:

  1. Minimal: add env_file to UNSUPPORTED_SERVICE_KEYS as a non-blocking warning ("env_file is not read — add these variables to the service's environment"). It's small and honest, but the values still don't arrive.
  2. Fuller: during the scan, read each service's env_file paths through the same source reader that already fetches the compose-adjacent .env, relative to the compose file's directory. Merge them below environment: with Compose's precedence, honour required: false, and treat values as secrets the way rootEnv does.

One more thing: I couldn't find where the dashboard renders unsupportedCompose from the prepare response. If it isn't shown, option 1 only helps API clients.

Activity

0

No activity yet.