One Dockerfile Per Environment

dockerfile: now resolves per environment, and --all refuses to run when environments disagree on which image to build.

4 min read v0.24.5

Pointing at a Dockerfile that isn't at the root

dockerfile: ./docker/Dockerfile

Paths are relative to the project root, and — this catches people — the build context is always the project root, wherever dockerfile: points. A COPY . /app line behaves the same regardless of which subfolder the Dockerfile itself lives in.

Per environment

dockerfile: ./docker/Dockerfile

environments:
  staging:
    dockerfile: ./docker/Dockerfile.staging   # overrides the top-level one
  production:
    # no dockerfile: here — inherits ./docker/Dockerfile
    server: prod-box

Resolution order, highest first: --dockerfile flag, then the environment's dockerfile:, then the top-level one, then a bare ./Dockerfile. A path an environment names but that doesn't exist on disk is a hard error — not a silent fallback to the default, which would build the wrong thing without telling you.

Why --all checks for agreement

neo deploy --all builds one image and ships it to every environment. If staging and production name different Dockerfiles, there is no single image that's correct for both — so Neo refuses the run and shows the conflict:

✗ --all builds one image, but these environments ask for different Dockerfiles:
  → docker/Dockerfile.staging → staging
  → docker/Dockerfile → production

Deploy them individually with neo deploy --to <environment>, or pass --dockerfile to force one Dockerfile for the whole run.

Try it yourself — Neo is free, with every feature unlocked.

Get started free