Skip to content
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

Reduce Dockerfile layers and optimize build #2913

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

YoussefBayouli
Copy link

Combined multiple apk add steps in both stages to reduce the number of layers.

Removed the apk del --purge deps since curl and vim are still required, so no need to remove them.

Removed redundant apk --update since --no-cache already ensures that the latest package versions are installed without caching.

…allation and cleanup steps

Combined multiple apk add steps in both stages to reduce the number of layers.

Removed the apk del --purge deps since curl and vim are still required, so no need to remove them.

Removed redundant apk --update since --no-cache already ensures that the latest package versions are installed without caching.
@derailed derailed added enhancement New feature or request question Further information is requested labels Oct 12, 2024
@derailed
Copy link
Owner

@YoussefBayouli Thank you for this update!
Unless I am missing it, the resulting image size is now ~135mb vs ~99.8mb ;(

Removed Build-time Dependencies: 
In the build stage, I removed the unnecessary build tools (gcc, make, git, etc.) after building the k9s binary. These tools are no longer needed, and deleting them helps reduce the size of the build layer.

Cleaned Up kubectl Artifacts: 
After downloading kubectl, the kubectl.sha256 file (or other temporary files generated by the download process) could take up unnecessary space, so I added a cleanup step to remove them.

Hope it helps :D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants