bcgov / bcgov/entity

Optimize Docker Image Size

Open
#34,618 0 comments 0 reactions 0 assignees View on GitHub
SRE techdebt
Dominant language
JavaScript
Stars
23
Forks
62
Avg merge
24m
Merged PRs (30d)
1

Description

**Summary**
Reduce Docker image size to improve deployment speed, decrease storage consumption, and minimize security exposure from unnecessary packages and dependencies.

**Description**
Review the current Docker image build process and identify opportunities to reduce image size. This may include:

- Coordinate with product teams with the code changes.
- Using a smaller base image where appropriate.(https://github.com/googlecontainertools/distroless)
- Implementing multi-stage builds.(https://github.com/GoogleContainerTools/distroless/blob/main/examples/python3-requirements/Dockerfile)
- Removing unnecessary packages, build tools, and cached files.
- Consolidating image layers where practical.
- Excluding non-essential files through .dockerignore.
- Verifying that application functionality remains unchanged after optimization.
- Verifying flask db upgrade remains functioning.

**Acceptance Criteria**

- Docker image size is reduced compared to the current baseline.
- Application functionality and performance are validated after optimization.
- Build and deployment pipelines continue to operate successfully.
- Changes are documented, including before-and-after image size metrics.
- Any base image or dependency changes are reviewed and approved.

**Definition of Done**

- Optimized Dockerfile committed to source control.
- CI/CD pipeline passes successfully.
- Image size reduction documented in the ticket.
- Container vulnerability scan results show improvement compared to the baseline image.

**Example**
https://github.com/bcgov/bcros-common/blob/main/notify-service/notify-api/Dockerfile
https://console.cloud.google.com/artifacts/docker/c4hnrd-tools/northamerica-northeast1/cloud-run-repo/notify-api?project=c4hnrd-tools

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the current Dockerfile, .dockerignore, and build or deployment pipeline configuration, then measure the existing image size and review how the Flask application and `flask db upgrade` run in the container. Compare the optimized image against that baseline, verify application behavior and pipeline success, and document image-size and vulnerability-scan results.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, flask, python
Domain
backend, build-system, devops
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.