Skip to content

build(docker): slim prod image (1.08GB → 390MB) - #2

Merged
andreacw5 merged 1 commit into
developfrom
chore/slim-prod-image
Nov 2, 2026
Merged

andreacw5 merged 1 commit into
developfrom
chore/slim-prod-image

Conversation

@andreacw5

Copy link
Copy Markdown
Contributor
  • Prune cleanup (same block as fileharbor): after pnpm prune --prod, remove the prisma CLI and what it drags in as a resolved peer of @prisma/client (@prisma/studio-core, @prisma/engines, @prisma/dev, @electric-sql/pglite, typescript, effect, react, react-dom), plus the Prisma query compilers for cockroachdb, mysql, sqlite, sqlserver. Migrations aren't run from this image.
  • No libvips: libvips-dev (and the hundreds of MB of -dev packages it pulls) removed from the prod stage. No sharp/vips in package.json, pnpm-lock.yaml or src/.
  • Fewer prod layers: apt-get upgrade and npm uninstall -g npm corepack in one RUN, like bastion.
  • No builder toolchain: build-essential python3 curl ca-certificates gcc g++ make removed from the builder. No prod dependency ships a binding.gyp or .node; the build passes without them.
  • .dockerignore gets *.tsbuildinfo: a leftover local tsconfig.build.tsbuildinfo was copied into the context, so incremental tsc skipped emitting and the image had no dist/main.js (local builds only; CI's clean checkout has no buildinfo). Same rule as the template.
image (docker image ls) before after
--target prod 1.08GB 390MB

Verified: no require() of the removed packages in the image's dist/; on a local Postgres with the migrations applied, the container starts and GET /health/ready returns 200 (database: up; Bastion unreachable, logged and retried as designed).

🤖 Generated with Claude Code

- drop what pnpm prune --prod keeps but the runtime never loads: the prisma
  CLI (a resolved peer of @prisma/client, pulling in studio, engines, pglite,
  typescript, effect, react) and the non-postgres query compilers
- drop libvips-dev from the prod stage: nothing in gatherly uses sharp
- one RUN for apt upgrade + npm uninstall
- no build toolchain in the builder: no native modules to compile
- ignore *.tsbuildinfo: a stale local one made nest build skip emitting
  dist/main.js in local image builds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@andreacw5
andreacw5 merged commit 2cd8ab9 into develop Nov 2, 2026
2 checks passed
@andreacw5
andreacw5 deleted the chore/slim-prod-image branch November 2, 2026 11:45
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.

1 participant