Skip to content

Conversation

@PeterDaveHello
Copy link

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.

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.
@PeterDaveHello
Copy link
Author

@josStorer hope you like it 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant