Skip to content

Dockerfile copies entire repo including node_modules causing 1.2GB image and slow push #1464

Description

@Junirezz

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

  • Add .dockerignore with node_modules, .git, dist, .next, coverage, *.log and use COPY package.json pnpm-lock.yaml ./ then RUN pnpm fetch before COPY backend ./
  • Multi-stage build: final stage FROM node:20-alpine with only dist and node_modules production deps
  • Test: build image and assert docker images size <500MB and no .git directory inside (docker run --rm image ls -la .git fails)
  • Existing docker compose up still works

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions