Optimize Dockerfile for smaller image size and faster build #416
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Consolidate apt commands, use shallow git clone, and prevent cache files
from being stored in the image. These changes reduce the final image
size from 12.9GB to 10.1GB (21.7% reduction).
The optimizations include:
rm -rf /var/lib/apt/lists/*to reduce size--no-cache-dirflag with pip to prevent cachinggit clonewith--depth 1for faster downloads--depth=1Image size reduced by 2.8GB, based on
docker imagesoutput:These changes follow Docker best practices by reducing layer count,
removing unnecessary files that would otherwise be stored in the image,
and improving CI efficiency, storage usage, and deployment speed in
production environments.