Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upbuild: add multi-stage build support #31257
Conversation
GordonTheTurtle
added
the
status/0-triage
label
Feb 22, 2017
icecrime
added
status/1-design-review
and removed
status/0-triage
labels
Feb 22, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
tonistiigi
Feb 22, 2017
Member
@johnstep @jhowardmsft Do you know what may be the problem with windows test. TestBuildMultiStageArg passes so it shouldn't be completely broken.
|
@johnstep @jhowardmsft Do you know what may be the problem with windows test. |
tonistiigi
changed the title from
[wip] build: add multi-stage build support
to
build: add multi-stage build support
Feb 22, 2017
tonistiigi
added
the
status/failing-ci
label
Feb 22, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
ping @johnstep @jhowardmsft PTAL |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
anusha-ragunathan
Mar 7, 2017
Contributor
I tested the PR while building a lean network plugin and it works quite nicely! Design and testing LGTM.
|
I tested the PR while building a lean network plugin and it works quite nicely! Design and testing LGTM. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
A slight variant/alternative mentioned here: #31067 (comment) |
| return err | ||
| } | ||
| b.context, err = builder.MakeDockerImageContext(b.docker, b.image, dir) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
GordonTheTurtle
assigned
tiborvass
Mar 9, 2017
thaJeztah
added this to backlog
in maintainers-session
Mar 9, 2017
This was referenced Mar 9, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
I've not rebased this since #31236 needs to be merged before anyway. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
tonistiigi
Mar 16, 2017
Member
Based on #31067 (comment) I will reimplement this with COPY --context
|
Based on #31067 (comment) I will reimplement this with |
thaJeztah
removed this from backlog
in maintainers-session
Mar 16, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
simonferquel
Mar 16, 2017
Contributor
I think we need to explicitly forbid building / (or c:\) and /windows (or c:\windows) out of a Windows image. That would make the image very large, and might even fail because Windows has a concept of "exclusive openness" of files, that might make some system files not copyable
|
I think we need to explicitly forbid building |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
tonistiigi
Mar 18, 2017
Member
I have updated this PR to the new COPY --context=n syntax. Named addressing should be in a separate PR.
PTAL @dnephin @dmcgowan @simonferquel @philtay
Could I move it to code-review now as the design was discussed in the previous implementations and a decision was made in the favor of this?
|
I have updated this PR to the new PTAL @dnephin @dmcgowan @simonferquel @philtay Could I move it to code-review now as the design was discussed in the previous implementations and a decision was made in the favor of this? |
tonistiigi
added
rebuild/experimental
and removed
rebuild/experimental
labels
Mar 18, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
philtay
Mar 18, 2017
Looks good. Thinking about the "zero case", I'm not sure if context=0 actually makes sense. Probably a simple COPY, without the context flag, should imply context=0. If we give to the initial context a number now (i.e. zero), we'll be forced to give it a name later for consistency (following named contexts PR). While it's easy (syntax-wise) to give the user the ability to name contexts from 1 onward, I don't see an elegant way to let them specify a name for the initial context.
Moreover it's debatable if a case like this one should really fail.
FROM busybox
COPY --context=0 foo barEven if we're clearly not in a nested build situation, the context=0 flag refers to the initial context. Thus, in theory, it should work. Omitting a number/name for the initial context would solve these little ambiguities and it feels (at least to me) more consistent with the actual behavior (i.e. you can COPY only from the initial context without having to specify a flag).
philtay
commented
Mar 18, 2017
|
Looks good. Thinking about the "zero case", I'm not sure if Moreover it's debatable if a case like this one should really fail. FROM busybox
COPY --context=0 foo barEven if we're clearly not in a nested build situation, the |
tonistiigi
removed
the
status/failing-ci
label
Mar 18, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
tonistiigi
Mar 18, 2017
Member
@philtay The numbers mean the index of a build block that is defined by FROM. Accessing user files is different and doesn't require any flags. I think there is no confusion understanding that numbers start with 0. I'll change the error message to the case you pointed out so it clearly states that this copy would mean source and destination are already the same. After the naming is implemented in the next step the indexes would be minimally used anyway.
|
@philtay The numbers mean the index of a build block that is defined by |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
philtay
Mar 18, 2017
@tonistiigi I misunderstood the meaning of context=0, thanks for the explanation. LGTM.
philtay
commented
Mar 18, 2017
|
@tonistiigi I misunderstood the meaning of |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
How about calling it |
tonistiigi
added some commits
Mar 16, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
tonistiigi
Mar 20, 2017
Member
@AkihiroSuda That is bit too verbose to my taste. I'd rather prefer --from then but it may be confused with FROM.
I have updated this PR so it doesn't depend on any other PRs. PTAL.
|
@AkihiroSuda That is bit too verbose to my taste. I'd rather prefer I have updated this PR so it doesn't depend on any other PRs. PTAL. |
tonistiigi
referenced this pull request
Mar 20, 2017
Closed
Fix ARG scoping for Dockerfiles with multiple FROM #31904
tonistiigi
referenced this pull request
Mar 24, 2017
Merged
Add support for named build stages #32063
tonistiigi
referenced this pull request
Mar 24, 2017
Merged
Fix integration tests build errors #32071
simonferquel
referenced this pull request
Mar 24, 2017
Merged
Multi stage builds cleanup for Windows #32084
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
StefanScherer
Mar 24, 2017
Contributor
Great. I've seen the tweets today, but first didn't understand why people are so happy about it. After reading #31067 I understood the benefit.
Some other captains discussed about the COPY --from=0 ... as it looks very low level.
Coincidentally I've seen some slides about Rocker (https://github.com/grammarly/rocker#exportimport) and their approach how to copy artifacts from a previous layer.
FROM google/golang:1.4
ADD . /src
WORKDIR /src
RUN CGO_ENABLED=0 go build -a -installsuffix cgo -v -o rocker.o rocker.go
EXPORT rocker.o
FROM busybox
IMPORT rocker.o /bin/rocker
CMD ["/bin/rocker"]As we haven't seen options to Dockerfile instructions I just wonder if the final syntax could more look like this?
|
Great. I've seen the tweets today, but first didn't understand why people are so happy about it. After reading #31067 I understood the benefit. FROM google/golang:1.4
ADD . /src
WORKDIR /src
RUN CGO_ENABLED=0 go build -a -installsuffix cgo -v -o rocker.o rocker.go
EXPORT rocker.o
FROM busybox
IMPORT rocker.o /bin/rocker
CMD ["/bin/rocker"]As we haven't seen options to Dockerfile instructions I just wonder if the final syntax could more look like this? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Just seen #32063, much better |
tonistiigi
referenced this pull request
Mar 24, 2017
Open
Proposal: add IMPORT/EXPORT commands to Dockerfile #32100
This was referenced Mar 25, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
dserodio
commented
Mar 28, 2017
|
I'm confused, what is the syntax that was merged in this PR? |
icecrime
referenced this pull request
Mar 30, 2017
Open
Use Docker's multi-staged build to produce a minimal image #48
AkihiroSuda
referenced this pull request
Apr 9, 2017
Open
Proposal: Independent RUN command in Dockerfile #32454
jorge07
referenced this pull request
Apr 12, 2017
Closed
Refactor gitlab-ci or replace for jenkinsfile #22
loicgelle
referenced this pull request
Apr 27, 2017
Open
Design questions: multi-stage builds and related subjects #32868
gaocegege
referenced this pull request
May 2, 2017
Open
Transfer from builder pattern to multi-stage docker build #21
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
alexisvincent
Jun 10, 2017
Is it possible to run the image from a particular stage?
For instance if I have build/dev tools in a "builder" stage. That I want to use interactively.
e.g.
docker run my-image --stage=builder some-useful-binary
alexisvincent
commented
Jun 10, 2017
|
Is it possible to run the image from a particular stage? For instance if I have build/dev tools in a "builder" stage. That I want to use interactively. e.g.
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
|
tonistiigi commentedFeb 22, 2017
•
edited
fixes #31067
fixes #31892
depends on #31236