Optimize Dockerfile for smaller image size and faster build#416
Open
PeterDaveHello wants to merge 1 commit intojosStorer:masterfrom
Open
Optimize Dockerfile for smaller image size and faster build#416PeterDaveHello wants to merge 1 commit intojosStorer:masterfrom
PeterDaveHello wants to merge 1 commit intojosStorer:masterfrom
Conversation
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:
- Replace apt with apt-get following container best practices
- Merge multiple apt commands into a single instruction to reduce layers
- Clean up apt cache with `rm -rf /var/lib/apt/lists/*` to reduce size
- Use `--no-cache-dir` flag with pip to prevent caching
- Use shallow `git clone` with `--depth 1` for faster downloads
- Also apply git shallow submodule initialization with `--depth=1`
Image size reduced by 2.8GB, based on `docker images` output:
REPOSITORY TAG IMAGE ID CREATED SIZE
rwkv-runner after b9f5f7cba3dd 36 minutes ago 10.1GB
rwkv-runner before 4fc66df1e9b8 50 minutes ago 12.9GB
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.
Author
|
@josStorer hope you like it 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.