Skip to content

docker: use multi-stage build#19789

Merged
lizan merged 13 commits intoenvoyproxy:mainfrom
lizan:docker_multistage
Feb 4, 2022
Merged

docker: use multi-stage build#19789
lizan merged 13 commits intoenvoyproxy:mainfrom
lizan:docker_multistage

Conversation

@lizan
Copy link
Copy Markdown
Member

@lizan lizan commented Feb 3, 2022

Use Docker multi-stage build and migrate all Docker image build process to docker buildx, this saves time and space by not loading images to Docker daemon during the build.

Risk Level: Low
Testing: CI
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: Lizan Zhou lizan@tetrate.io

Signed-off-by: Lizan Zhou <lizan@tetrate.io>
@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #19789 was opened by lizan.

see: more, trace.

Signed-off-by: Lizan Zhou <lizan@tetrate.io>
@moderation
Copy link
Copy Markdown
Contributor

Relevant re: removing Alpine images - #19781

lizan added 3 commits February 2, 2022 21:14
Signed-off-by: Lizan Zhou <lizan@tetrate.io>
Signed-off-by: Lizan Zhou <lizan@tetrate.io>
Signed-off-by: Lizan Zhou <lizan@tetrate.io>
@lizan lizan marked this pull request as ready for review February 3, 2022 08:17
@lizan lizan requested a review from phlax February 3, 2022 08:17
Signed-off-by: Lizan Zhou <lizan@tetrate.io>
@phlax phlax self-assigned this Feb 3, 2022
@phlax
Copy link
Copy Markdown
Member

phlax commented Feb 3, 2022

great idea for reducing size!

seems like there is a syntax error of some sort in ci/do_ci.sh

Signed-off-by: Lizan Zhou <lizan@tetrate.io>
@lizan
Copy link
Copy Markdown
Member Author

lizan commented Feb 3, 2022

@phlax this should be good to go

lizan added 5 commits February 3, 2022 19:02
Signed-off-by: Lizan Zhou <lizan@tetrate.io>
Signed-off-by: Lizan Zhou <lizan@tetrate.io>
Signed-off-by: Lizan Zhou <lizan@tetrate.io>
Signed-off-by: Lizan Zhou <lizan@tetrate.io>
@lizan lizan force-pushed the docker_multistage branch from e0d8623 to 65f5972 Compare February 4, 2022 07:38
phlax
phlax previously approved these changes Feb 4, 2022
Copy link
Copy Markdown
Member

@phlax phlax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, with a small nit about making the Dockerfile a little clearer - ill leave it to you to address/ignore

i wasnt aware of skopeo until now, looks v useful

the idea of prebuilding the image with the binary is really cool, altho it still seems to be sending a huge context - im wondering if it is worth building the image with the binaries and then deleting them before building the rest or similar. I just think it would speed it up quite a bit not copying out gbs of data

either way i think this is a great improvement on current, so lgtm - hopefully it address the size issue

Signed-off-by: Lizan Zhou <lizan@tetrate.io>
Copy link
Copy Markdown
Member

@phlax phlax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks

@lizan
Copy link
Copy Markdown
Member Author

lizan commented Feb 4, 2022

the idea of prebuilding the image with the binary is really cool, altho it still seems to be sending a huge context - im wondering if it is worth building the image with the binaries and then deleting them before building the rest or similar. I just think it would speed it up quite a bit not copying out gbs of data

Looking at the log I don't think BuildKit sends duplicate context, we have {envoy,envoy-contrib}-{release,debug}-{amd64,arm64} combination and it seems only sends them once each. For disk space it now ending the job with 19GB available vs 9.6GB available before this PR, the job starting with 34GB.

@lizan lizan enabled auto-merge (squash) February 4, 2022 18:45
@lizan lizan merged commit fd978dd into envoyproxy:main Feb 4, 2022
@lizan lizan deleted the docker_multistage branch February 4, 2022 20:38
@PiotrSikora
Copy link
Copy Markdown
Contributor

Thanks!

joshperry pushed a commit to joshperry/envoy that referenced this pull request Feb 13, 2022
Use Docker multi-stage build and migrate all Docker image build process to `docker buildx`, this saves time and space by not loading images to Docker daemon during the build.

Risk Level: Low
Testing: CI
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: Lizan Zhou <lizan@tetrate.io>
Signed-off-by: Josh Perry <josh.perry@mx.com>
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.

4 participants