build: add multi-stage build support#31257
Conversation
|
@johnstep @jhowardmsft Do you know what may be the problem with windows test. |
|
ping @johnstep @jhowardmsft PTAL |
d3f9f50 to
cf2ac93
Compare
|
I tested the PR while building a lean network plugin and it works quite nicely! Design and testing LGTM. |
|
A slight variant/alternative mentioned here: #31067 (comment) |
builder/dockerfile/dispatchers.go
Outdated
There was a problem hiding this comment.
note to self: make sure old context is closed
|
I've not rebased this since #31236 needs to be merged before anyway. |
|
Based on #31067 (comment) I will reimplement this with |
|
I think we need to explicitly forbid building |
88d312c to
f0781af
Compare
|
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? |
|
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 |
bd8e3eb to
ef29297
Compare
|
@philtay The numbers mean the index of a build block that is defined by |
|
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? |
|
Just seen #32063, much better ❤️ |
|
I'm confused, what is the syntax that was merged in this PR? |
|
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. |
|
|
|
Thank you everyone for working on it. |
fixes #31067
fixes #31892
depends on #31236