Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Optimize Docker build #2464

Closed
chevdor opened this issue May 3, 2019 · 6 comments
Closed

Optimize Docker build #2464

chevdor opened this issue May 3, 2019 · 6 comments
Labels
U3-nice_to_have Issue is worth doing eventually.

Comments

@chevdor
Copy link
Contributor

chevdor commented May 3, 2019

Currently, .dockerignore does not exclude .git.
AFAIK, the .git folder is only required by ./scripts/build.sh to figure out what is the root folder.

Finding another way to identify the root folder (currently PROJECT_ROOT=git rev-parse --show-toplevel) allows to exclude the .git folder and avoid what is currently the copy of around 800+MB to the first stage image.

@chevdor chevdor added the U3-nice_to_have Issue is worth doing eventually. label May 3, 2019
@folsen
Copy link
Contributor

folsen commented Jun 4, 2019

@TriplEight sorry to add you to a bunch of things, but maybe you can take a look at this one too?

@TriplEight
Copy link
Contributor

TriplEight commented Jun 4, 2019

@chevdor could you specify which docker build do you mean: parity/substrate or parity/rust-builder?
First one just copies substrate's binary, second anyways git fetches the whole repository every CI job.

@chevdor
Copy link
Contributor Author

chevdor commented Jun 5, 2019

I was referring to https://github.com/paritytech/substrate/blob/master/Dockerfile
In the current version, the build.sh script needs the .git folder but only to find the root folder of the project magically. If we find a way to do it without needing the .git folder (which is not needed otherwise), we spare the copy (take time and space) of ~800MB and growing. The first stage image is already very fat so losing this weight would be very beneficial, especially for CI.

@TriplEight
Copy link
Contributor

@chevdor
The thing is our current CI (GitLab) makes use of this Dockerfile: https://github.com/paritytech/scripts/blob/master/docker-files-for-Gitlab-CI-rust/rust-builder/Dockerfile
This image is universal builder for Substrate based projects.

And this image https://github.com/paritytech/substrate/blob/master/scripts/docker/Dockerfile is used for publishing Substrate's binary.

I'm not aware if the Dockerfile you are talking about is being used anywhere, please tell me if it is.

@ltfschoen
Copy link
Contributor

@chevdor @TriplEight could we close this issue now that #13472 has been merged (where we used BASH_SOURCE to find project root instead of using the .git folder, and and where we added a docker/substrate_builder.Dockerfile.dockerignore file to exclude .git from the docker build to reduce the docker image size to ~277MB).

@chevdor
Copy link
Contributor Author

chevdor commented Mar 9, 2023

Nicely done @ltfschoen, I see no problem closing this issue now so I will just do that, @TriplEight feel free to reopen if you see something missing.

@chevdor chevdor closed this as completed Mar 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
U3-nice_to_have Issue is worth doing eventually.
Projects
None yet
Development

No branches or pull requests

4 participants