Skip to content

feat: add multi-stage build with slim prod target#3

Merged
Bonajo merged 2 commits into
mainfrom
multi-stage-prod-target
May 28, 2026
Merged

feat: add multi-stage build with slim prod target#3
Bonajo merged 2 commits into
mainfrom
multi-stage-prod-target

Conversation

@lenntt
Copy link
Copy Markdown
Contributor

@lenntt lenntt commented May 27, 2026

Summary

Adds a prod target alongside the existing dev image. Motivation: downstream consumers (the new FontysVenlo developer platform CI pipeline, see UOL1.1-Template#8) need an image with the same PHP + extensions as the devcontainer image, but without the devcontainer tooling (git, gnupg, zip CLI, devuser) and without php.ini-development. Today they'd have to either mirror this Dockerfile downstream (drift risk) or accept a bloated prod image with display_errors=On. Multi-stage here keeps a single source of truth.

Design choices (please weigh in)

  • base stage is private — installs Apache + PHP 8.2.29 + all PHP extensions + ServerName localhost. Both dev and prod extend it, so any code that runs against dev runs against prod.
  • dev is last so docker build . (no --target) keeps producing the dev image — no breaking change for existing consumers.
  • Prod uses php.ini-production (display_errors=Off, log_errors=On) — the more conservative default for an image shared beyond uol11. If you'd rather keep error visibility in student deployments to aid debugging, it's a one-line flip in the prod stage; happy to switch.
  • Upload limits (upload_max_filesize=20M, post_max_size=80M) are applied in both targets so file-upload behaviour matches between dev and prod regardless of base ini.
  • No devuser in prod — Apache runs as default www-data.

Tags published

Tag Target Notes
sebivenlo/prj1-web:<version> dev unchanged behaviour
sebivenlo/prj1-web:<version>-prod prod new; flavor: suffix=-prod in CI

Both build.yml (PR check) and release.yml (tag push) now build both targets. Release pushes both multi-arch (amd64+arm64).

Test plan

  • docker build --target prod . succeeds locally
  • docker build --target dev . succeeds locally
  • Both targets have identical PHP extensions: pdo, pdo_pgsql, gd, exif, zip
  • Both targets: upload_max_filesize=20M, post_max_size=80M
  • Prod: display_errors=Off; dev: display_errors=On
  • Dev has git and zip CLI; prod does not
  • CI green on both build.yml jobs (Build dev / Build prod)
  • After merge + tag, both image tags appear on Docker Hub (<version> and <version>-prod)

Adds a prod target alongside the existing dev image so deployments
(e.g. the FontysVenlo developer platform) can use the same base PHP +
extensions without inheriting devcontainer tooling and the development
php.ini.

Stage layout:
  base — shared Apache + PHP 8.2.29 + extensions + ServerName (never built
         directly; consumers must pass --target).
  prod — base + php.ini-production with the same upload_max_filesize=20M
         and post_max_size=80M overrides as dev, so file-upload behaviour
         matches. No git/gnupg/zip CLI, no devuser.
  dev  — base + git/gnupg/zip CLI + devuser + php.ini-development. Stays
         last so `docker build .` keeps producing the dev image and no
         existing consumer breaks.

CI publishes both:
  sebivenlo/prj1-web:<version>      (dev, unchanged)
  sebivenlo/prj1-web:<version>-prod (new)

Verified locally: both targets carry pdo, pdo_pgsql, gd, exif, zip;
upload limits match; display_errors is On in dev and Off in prod;
dev has git+zip CLI, prod does not.
@lenntt lenntt requested a review from Bonajo May 27, 2026 18:31
@lenntt lenntt marked this pull request as ready for review May 27, 2026 18:33
Clears the Node runtime deprecation warnings emitted by the older majors:

  actions/checkout            @V3 -> @v4
  docker/setup-qemu-action    @v2 -> @V3
  docker/setup-buildx-action  @v2 -> @V3
  docker/metadata-action      @v4 -> @v5
  docker/login-action         @v2 -> @V3
  docker/build-push-action    @v4 -> @v6

No input/output schema changes for the way these are used here, so the
workflows behave identically aside from running on a newer runtime.
@Bonajo Bonajo merged commit 607ce0e into main May 28, 2026
1 check passed
@Bonajo Bonajo deleted the multi-stage-prod-target branch May 28, 2026 06:25
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.

2 participants