Skip to content

Optimize API and dashboard Docker images — remove workspace bloat #32

@rustydb

Description

@rustydb

Priority: P1

Source

Senior Architect Code Review (2026-04-03)

Problem

The API and dashboard production Dockerfiles use COPY --from=build /app /app which copies the entire workspace into the runner stage — including node_modules, all source files, build artifacts, and test files. This results in unnecessarily large production images (potentially hundreds of MB of dead weight).

Affected Files

  • apps/api/Dockerfile
  • apps/dashboard/Dockerfile

Current Pattern

# API Dockerfile - runner stage
FROM    docker.io/oven/bun:1.3.11 AS runner
WORKDIR /app
COPY    --from=build /app /app    # <-- copies EVERYTHING

Recommendation

API: Copy only the runtime files needed:

  • apps/api/src/ (Bun runs TypeScript directly)
  • packages/shared-types/src/
  • node_modules/ (or better, use bun install --production)
  • package.json files

Dashboard: The dashboard builds to static assets. The runner should:

  • Copy only apps/dashboard/dist/ and apps/dashboard/server.ts
  • Install only production dependencies
  • Serve the static build via the Express server

Acceptance Criteria

  • API runner image contains only runtime-necessary files
  • Dashboard runner image contains only the built static assets and server
  • Production images use --production dependency installation where possible
  • Image sizes are reduced by at least 50%
  • Both services still start and function correctly

Metadata

Metadata

Assignees

No one assigned

    Labels

    docker_composePull requests that update docker_compose codeenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions