docker: optimize backend/frontend images for #1335 (non-root, healthc… - #1414
Open
Nishant-S-Bhardwaj wants to merge 3 commits into
Open
docker: optimize backend/frontend images for #1335 (non-root, healthc…#1414Nishant-S-Bhardwaj wants to merge 3 commits into
Nishant-S-Bhardwaj wants to merge 3 commits into
Conversation
…, healthchecks, size reduction - see PR description for details)
Nishant-S-Bhardwaj
force-pushed
the
docker-optimization-1335
branch
from
August 31, 2026 07:46
90c0dc1 to
1a1f313
Compare
Author
Collaborator
|
resolve conflict on this issue @Nishant-S-Bhardwaj |
Author
Conflict Resolved @K1NGD4VID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
Optimizes backend and frontend Docker images for size, security (non-root), and adds native healthchecks, per #1335.
Type of Change
Related Issues
Relates to #1335 (size targets not fully met — see notes below, with evidence)
Changes Made
Backend (
backend/Dockerfile):nodeuser (previously ran as root)HEALTHCHECKprobing/health(no curl/wget needed)@prisma/client(a real prod dependency) hasprismaas a peer dependency, which pulls in@prisma/devandtypescriptregardless of--omit=dev. These are needed at runtime because.github/workflows/ci.ymlrunsnpx prisma db pushagainst this exact container as part of its health-check step. Tested--omit=peer— gets much closer to target but breaksnpx prisma db push(confirmed viadocker run ... npx prisma --versionfailing once peers were omitted). Flagging for maintainer input: accept 726MB as evidence-backed, or moveprisma db pushout of the runtime image into a separate CI-only step so--omit=peerbecomes safe.Frontend (
frontend/Dockerfile,frontend/next.config.ts,frontend/src/app/health/route.ts):output: 'standalone'tonext.config.tsnodeuser, nativeHEALTHCHECK/healthroute existed anywhere in the frontend before this PR — added a minimal one returning{ status: "ok" }docker images, but actual in-container filesystem size (du -sh /) is ~179MB. Gap persisted after a full build-cache prune and clean rebuild with--provenance=false, so it doesn't appear to be attestation/cache bloat — likely Docker's size-reporting overhead on this Docker version. Both numbers disclosed for transparency.Both:
npm installinstead ofnpm ci: repo uses npm workspaces with a single root-level lockfile;npm cifails from a workspace subdirectory. Switching would require restructuring the build context to the repo root (affects both Dockerfiles +docker-compose.yml) — flagging as a follow-up, kept out of scope here..dockerignorefor both servicesKnown gap:
docker-compose.ymlwas not updated (frontend has no healthcheck wired there yet). Happy to add if maintainers want it in this PR rather than a follow-up.Testing
Test Steps
docker run --rm <image> sh -c "whoami && npx prisma --version"— confirmed running asnode, prisma CLI functionaldocker compose up, confirmeddocker inspect --format='{{json .State.Health}}'reports"Status":"healthy"with real 200 responses logged/healthreturns200 {"status":"ok"}locally before building it into the imagedocker imagesagainstdu -sh /inside a running container, re-verified afterdocker builder prune -af+ fresh buildTest Coverage
Additional Notes
Reporting both measured sizes rather than only the target numbers, since 150MB/120MB weren't fully achievable without either breaking a CI-required step (backend) or an unresolved Docker size-reporting discrepancy (frontend). Open to guidance on trade-offs above.