New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement] Disable pip cache in Dockerfiles to reduce image size #878
Conversation
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. PR Description updated to latest commit (3833d0f)
|
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. PR Review
✨ Review tool usage guide:Overview: The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
See the review usage page for a comprehensive guide on using this tool. |
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. PR Code Suggestions
✨ Improve tool usage guide:Overview:
See the improve usage page for a comprehensive guide on using this tool. |
@idubnori What are the downside of adding this line ? why it is not enabled by default ? |
@mrT23 Thank you for your reply.
I think no downside as long as using inside dockerfile. The pip cache should be intended to eliminate the need to re-download the same package file locally. There is no scenario cached packages are reused in the current dockerfile.
If you are building docker in a local environment, the previous layer cache will not be reused, so pip install will be re-run only for the first time build after this changes. After that, unless the
If building an other docker image based on the pr-agent docker image, it may be less risky to leave the cache in place, but I think it is the edge case. To minimize the version problem or risk, instead of disabling the pip cache, I think use cache purge after pip install, rather than disabling the pip cache. (use |
If more concerns or questions, I would like to suggest wait for comments from other contributors or PR can be closed. This PR is not very effective, also not important for me at this time. |
/describe |
sss |
PR Description updated to latest commit (3833d0f)
|
ok, thanks @idubnori |
User description
Remove the pip cache is created when pip install from the docker image layer. Currently, 80MB is being consumed needlessly and reduce it.
$ docker images | grep pr-agent pr-agent no-pip-cache 3f43414e6ff8 About a minute ago 1.3GB codiumai/pr-agent github_action 3b96010bd372 4 days ago 1.38GB
Note
ARG PIP_NO_CACHE_DIR=1
ref. https://stackoverflow.com/a/60270281/4252588
80MB is being consumed needlessly.
You can see it using dive
shim
ordistroless
image and multi-stage buildType
enhancement
Description
ARG PIP_NO_CACHE_DIR=1
to Dockerfiles to disable pip cache, reducing the image size across different Docker configurations.Changes walkthrough
Dockerfile.github_action
Disable pip cache in GitHub Actions Dockerfile
Dockerfile.github_action
ARG PIP_NO_CACHE_DIR=1
to disable pip cache and reduce imagesize.
Dockerfile
Disable pip cache in main Dockerfile
docker/Dockerfile
ARG PIP_NO_CACHE_DIR=1
to disable pip cache and reduce imagesize.
Dockerfile.lambda
Disable pip cache in Lambda Dockerfile
docker/Dockerfile.lambda
ARG PIP_NO_CACHE_DIR=1
to disable pip cache in AWS Lambda Dockerimage.