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

Use Docker's multi-stage builds to reduce image size #3

Merged
merged 1 commit into from
Apr 22, 2022
Merged

Use Docker's multi-stage builds to reduce image size #3

merged 1 commit into from
Apr 22, 2022

Conversation

Hazmi35
Copy link
Contributor

@Hazmi35 Hazmi35 commented Apr 22, 2022

Docker images is built up from a series of layers. Each layer represents an instruction in the image’s Dockerfile. Meaning every instructions in the image's Dockerfile will have it's own layer, and will still exists on the final image.

I see that in line 20 on original Dockerfile, you are removing some dirty stuffs from gradle for runtime, that's good, but what you don't know that there is still a leftover in /root/.gradle, you could also remove it manually using rm but using multi-stage like this is more proper/better or you can say clean

With multi-stage builds, every dirty stuffs while compiling will not go into the final image, so no need to delete /root/.gradle or even /tmp/*, so with that, this PR will reduce image size from 514MB to 232MB

Old image layers:
image

New image layers:
image

And, on the final layer of new image:
image

@akbaryahya
Copy link
Collaborator

interesting, I just realized there is something left in root folder, I will try to finish #2 first and tonight I will make an image.
once again thank you

@Hazmi35
Copy link
Contributor Author

Hazmi35 commented Apr 22, 2022

Just rebased with main branch, this PR is ready

@akbaryahya akbaryahya merged commit 858305b into YuukiPS:main Apr 22, 2022
@Hazmi35
Copy link
Contributor Author

Hazmi35 commented Apr 22, 2022

interesting, I just realized there is something left in root folder, I will try to finish #2 first and tonight I will make an image. once again thank you

Why not build the image in GitHub Actions?

@akbaryahya
Copy link
Collaborator

actually i want to use it but i still don't know how to use it and when it was v1.0 it was too big so i thought it was not enough :/

@Hazmi35 Hazmi35 deleted the feat/multi-stage-builds branch April 22, 2022 05:47
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.

2 participants