Skip to content

Optimize Dockerfile-aws with multi-stage build #673#684

Open
drakeredwind01 wants to merge 5 commits into
mainfrom
drake_673_optimize_dockerfile_aws
Open

Optimize Dockerfile-aws with multi-stage build #673#684
drakeredwind01 wants to merge 5 commits into
mainfrom
drake_673_optimize_dockerfile_aws

Conversation

@drakeredwind01

@drakeredwind01 drakeredwind01 commented Jun 12, 2026

Copy link
Copy Markdown
Member

Fixes #673

Optimize Dockerfile-aws with multi-stage build #673

Pre-implementation concerns

1. Size savings will be modest
The cache mounts (--mount=type=cache) added in the previous PR already keep pip/apk caches out of image layers. Savings here are mainly removing pip and uv from the final image.

2. staticfiles/ must be explicitly copied from builder to runtime stage
collectstatic runs in the builder stage and writes to staticfiles/. This directory must be COPY --from=builder'd into the runtime stage — whitenoise serves from it at runtime.

Size comparison

  • Single-stage: 74MB
  • Multi-stage: 62.3MB
  • ~16% reduction

Note: slightly larger than original measurement due to drf-spectacular and its dependencies being correctly included in the production image (fixed in PR #683).

Files updated:

  • app/Dockerfile-aws — refactored to two stages: builder stage installs deps and runs collectstatic; runtime stage copies site-packages, gunicorn binary, and app code from builder

Closes #219

Comment thread app/peopledepot/settings_aws.py Dismissed
@drakeredwind01 drakeredwind01 requested a review from fyliu June 12, 2026 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Optimize Dockerfile-aws with multi-stage build Create deployment docker setup (for dev env)

1 participant