Context
Dockerfile has COPY . . before RUN pnpm install, so local node_modules (800MB) and .git (300MB) are copied into build context and image.
Why this is a gap
Image is 1.2GB vs 300MB achievable, push to GHCR takes 4m and pulls on deploy are slow, and .git leaks commit history into image.
Acceptance Criteria
Context
DockerfilehasCOPY . .beforeRUN pnpm install, so localnode_modules(800MB) and.git(300MB) are copied into build context and image.Why this is a gap
Image is 1.2GB vs 300MB achievable, push to GHCR takes 4m and pulls on deploy are slow, and
.gitleaks commit history into image.Acceptance Criteria
.dockerignorewithnode_modules,.git,dist,.next,coverage,*.logand useCOPY package.json pnpm-lock.yaml ./thenRUN pnpm fetchbeforeCOPY backend ./FROM node:20-alpinewith onlydistandnode_modulesproduction depsdocker imagessize <500MB and no.gitdirectory inside (docker run --rm image ls -la .gitfails)docker compose upstill works