Skip to content

Updates the Dockerfile to use multi-stage#35100

Merged
vdemeester merged 1 commit intomoby:masterfrom
cpuguy83:multistage_dockerfile
Feb 26, 2018
Merged

Updates the Dockerfile to use multi-stage#35100
vdemeester merged 1 commit intomoby:masterfrom
cpuguy83:multistage_dockerfile

Conversation

@cpuguy83
Copy link
Copy Markdown
Member

@cpuguy83 cpuguy83 commented Oct 5, 2017

Posting this up here for others to contribute to.
IIRC the CI dockerd instances don't support multi-stage builds yet.

I'm not sure if this broke CRIU or not (I haven't tried to use CRIU in dind before and it definitely doesn't work with this PR).
Everything else seems to work.
I find this to be a little slower (haven't measured, not much but if you are paying attention you'd notice) to run the build from a full cache than the monolithic Dockerfile, but it makes it MUCH faster for individual changes to the dockerfile not requiring to rebuild basically the whole thing.

Dockerfile Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems unneeded

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like a bad rebase or so; I see && apt-get install -y curl at line 12 below, which probably had to be here

Dockerfile Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we make this Dockerfile to support other archs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Can we do it separately? I'd love to but I'm sure there must be other things that need to be done.
Also I'm not sure if the base images have multi-arch even though they provide manifest lists now?

Dockerfile Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How does it relate to golang?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The frozen image script is using go env.
This could be worked around, but I'd rather leave it as is for now.

Dockerfile Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we just use docker.io/library/golang? (cc @thaJeztah @justincormack )

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't know why we aren't using the golang image... it's come up before, just can't remember the details.

Dockerfile Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

unrelated to golang?

@AkihiroSuda
Copy link
Copy Markdown
Member

ping @cpuguy83 ^^

@cpuguy83 cpuguy83 force-pushed the multistage_dockerfile branch from 793d9be to 250c99a Compare December 11, 2017 16:39
@cpuguy83
Copy link
Copy Markdown
Member Author

I updated this... but of course our builders are still out of date.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not just use git -C here instead of doing a cd and then a git command?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These are copied from the old install-binaries.sh file. I'd prefer to optimize them separately.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same note here about git -C

Dockerfile Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

&& apt-get install -y curl

bad rebase?

@AkihiroSuda
Copy link
Copy Markdown
Member

ping ^^ @cpuguy83

@thaJeztah
Copy link
Copy Markdown
Member

I was also wondering if we should pin the Go version for the various upstream binaries (e.g., what if upstream RunC has only been tested/verified with Go 1.8?)

@cpuguy83
Copy link
Copy Markdown
Member Author

cpuguy83 commented Feb 6, 2018

We are also still waiting on Jenkins to be updated. There are a few issues on the nodes being tracked.

@psftw

@cpuguy83 cpuguy83 force-pushed the multistage_dockerfile branch from 250c99a to d017f2a Compare February 15, 2018 17:55
@thaJeztah
Copy link
Copy Markdown
Member

Hmf looks like this Jenkins isn’t update yet 😞

@thaJeztah
Copy link
Copy Markdown
Member

Binary installs were split off in #36336

@cpuguy83 cpuguy83 force-pushed the multistage_dockerfile branch 3 times, most recently from 63aaf8f to 2a0786c Compare February 22, 2018 19:13
Copy link
Copy Markdown
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

parallelization preview:

> docker build .
...
real	9m15.516s
user	0m2.052s
sys	0m0.880s

> buildctl build --frontend dockerfile.v0  --local context=. --local dockerfile=.

[+] Building 268.2s (61/61) FINISHED
...
real	4m28.229s
user	0m6.208s
sys	0m3.696s

Rebuild with cache for docker build --pull . is 9-10sec vs ~1-2 sec. in buildkit (almost all that time is spent verifying that the base images have not changed in registry as there is no tag cache).

Dockerfile Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd love if these versions would be defined in the top of the Dockerfile now so you could do things like docker build --build-arg RUNC_COMMIT=master .

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

^^ Good suggestion

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree. Can we get this change in and then start adding in new features?

@vdemeester
Copy link
Copy Markdown
Member

janky tests are ok, the binary cross got "cut" because the build ran for too long

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
@thaJeztah
Copy link
Copy Markdown
Member

Created follow-up issues for tracking:


FROM debian:stretch

FROM buildpack-deps:stretch AS base
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we start with golang image (which is essentially stretch with golang installed)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we could, cc @cpuguy83 👼

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

cc @tianon

I know this was attempted in the past, I don't recall why we didn't do it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If I recall correctly, at the time we were still using utilities that Ubuntu had better packaging for than Debian, so given we're on Debian now, it's likely OK. 👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yay 🎉

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See #36425 👼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants