Skip to content

Optimize Dockerfile-aws with multi-stage build #673

Description

@fyliu

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
  • 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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity: mediumStraightforward but some complexity (e.g., involves multiple files)dockerPull requests that update docker codefeature: infrastructureFor changes on site technical architecturerole: dev opss: PD teamstakeholder: People Depot Teamsize: 2ptCan be done in 7-12 hours
    No fields configured for Feature.

    Projects

    Status
    🆕New Issue Review

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions