From a0d8804a530ea6e847501dd678408ca40b28baeb Mon Sep 17 00:00:00 2001 From: Edwin van den Houdt Date: Thu, 30 Jul 2026 09:35:21 +0200 Subject: [PATCH] feat(backend): optional lean deployable image (WP-30 #5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Multi-stage backend/Dockerfile (sdk build -> aspnet:10.0 runtime, ~312MB) + docker-compose.prod.yml, additive only — not wired into CI or the existing dev docker-compose.yml (which keeps the SDK image for dotnet run hot-reload). New .dockerignore keeps the build context lean (node_modules alone is ~750MB) since the Dockerfile COPYs from the repo root to pick up public/letter.css (WP-25's FE<->BE letter contract) as a sibling of backend/. Verified for real: built the image, ran it, and curled a live GET /api/v1/brief/preview against the running container — got back the actual rendered letter HTML with letter.css inlined, confirming the walk-up-from-BaseDirectory lookup resolves inside this image layout too. Co-Authored-By: Claude Sonnet 5 --- .dockerignore | 12 ++++++++++++ backend/Dockerfile | 15 +++++++++++++++ docker-compose.prod.yml | 14 ++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 .dockerignore create mode 100644 backend/Dockerfile create mode 100644 docker-compose.prod.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..46cf95e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +# WP-30: backend/Dockerfile does `COPY . .` from the repo root (needs public/letter.css as a +# sibling of backend/) — without this, that copy would drag in node_modules (~750MB), .git, +# and every build/output directory, defeating the point of a "lean" image. +.git +node_modules +dist +storybook-static +backend/**/bin +backend/**/obj +backend/**/bigregister.db* +backend/openzaak +documentation.json diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..366b351 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,15 @@ +# WP-30: lean deployable image (optional — not used by the dev demo, which keeps the SDK +# image in the root docker-compose.yml for `dotnet run` hot-reload). Build from the repo +# root: `docker build -f backend/Dockerfile .` +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build +WORKDIR /src +COPY . . +RUN dotnet publish backend/src/BigRegister.Api -c Release -o /app + +FROM mcr.microsoft.com/dotnet/aspnet:10.0 +WORKDIR /app +COPY --from=build /app . +# LetterHtml.Render (WP-25) walks up from AppContext.BaseDirectory looking for a sibling +# public/letter.css (the FE⇄BE letter contract) — this keeps that lookup working here too. +COPY public ./public +ENTRYPOINT ["dotnet", "BigRegister.Api.dll"] diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000..3aec3c3 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,14 @@ +# WP-30: optional lean deployable backend image — NOT used by the dev demo (docker-compose.yml +# keeps the SDK image there for `dotnet run` hot-reload; rewriting that one into a prod image +# would lose the bind-mount hot-reload it's for). This is an additive artifact only, not wired +# into CI. `docker compose -f docker-compose.prod.yml up --build` → Swagger at :5000/swagger. +services: + api: + build: + context: . + dockerfile: backend/Dockerfile + environment: + - ASPNETCORE_ENVIRONMENT=Production + - ASPNETCORE_URLS=http://+:8080 + ports: + - '5000:8080'