hackforla / hackforla/peopledepot

Optimize Dockerfile-aws with multi-stage build

Open
#673 0 comments 0 reactions 0 assignees View on GitHub
complexity: medium docker feature: infrastructure role: dev ops s: PD team size: 2pt
Dominant language
Python
Stars
14
Forks
37
Avg merge
9d 15h
Merged PRs (30d)
5

Description

### Overview

Refactor `Dockerfile-aws` to use a multi-stage build to reduce the final production image size. This removes build-time dependencies and temporary files that don't need to be in the final image.

### Action Items
- [ ] Refactor `app/Dockerfile-aws` to use a multi-stage build:
- [ ] Stage 1: Builder stage that installs dependencies and runs `collectstatic`
- [ ] Stage 2: Runtime stage that copies only what's needed from the builder
- [ ] Remove build artifacts and cache from the final image
- [ ] Compare final image sizes before and after optimization
- [ ] Test that the optimized image builds successfully and the app runs correctly
- [ ] Document any image size improvements

### Acceptance Criteria
- Multi-stage build is implemented in `Dockerfile-aws`
- Final image size is smaller than the single-stage version
- App starts and serves static files correctly in the optimized image
- Build process completes without errors
- Image size comparison is documented (in commit message or PR description)

### References
- [Docker multi-stage builds](https://docs.docker.com/build/building/multi-stage/)
- We're not sure how much this will reduce the image size, since we already have method to remove build caches from the image.

**Parent Issue**: #219
**Blocked by**: #219 sub-issue "Add gunicorn and Whitenoise, and set up Dockerfile-aws and entrypoint-aws.sh"

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.