-
Notifications
You must be signed in to change notification settings - Fork 787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --target to bud command #1321
Add --target to bud command #1321
Conversation
@mheon FYI. I'll need to touch up the man page on Podman and vendor Buildah once this rumbles through. |
SGTM |
imagebuildah/build.go
Outdated
if (options.Target != "") { | ||
stagesTargeted, ok := stages.ByTarget(options.Target) | ||
if !ok { | ||
return "", nil, errors.Wrapf(err, "The target %q was not found in the provided Dockerfile", options.Target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did the err come from? I think this is a bug. Should just be a errors.Errorf()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, cut/paste error from imagebuilder, I'll touch it up.
20d8a32
to
984bbaa
Compare
Repushed with gofmt tended to and @rhatdan's comment addressed. |
LGTM |
FROM fedora:latest | ||
RUN touch /foo | ||
|
||
FROM alpine:latest AS mytarget |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add one more stage after this to ensure that it is skipped when --target it set to mytarget. To ensure we don't accidentally regress in future code changes.
One comment, but LGTM |
Moby seems to behave differently. Currently, we only execute the target but Moby is stopping at the specified target and executes all previous stages. FROM alpine:latest as one
RUN touch ~/alpine.txt
FROM centos:latest as centos
RUN touch ~/centos.txt
FROM fedora:latest as fedora
RUN touch ~/fedora.txt Running Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM alpine:latest as one
latest: Pulling from library/alpine
6c40cc604d8e: Pull complete
Digest: sha256:b3dbf31b77fd99d9c08f780ce6f5282aba076d70a513a8be859d8d3a4d0c92b8
Status: Downloaded newer image for alpine:latest
---> caf27325b298
Step 2/4 : RUN touch ~/alpine.txt
---> Running in 923b3b87dfd6
Removing intermediate container 923b3b87dfd6
---> 544aae7ed2c4
Step 3/4 : FROM centos:latest as centos
latest: Pulling from library/centos
a02a4930cb5d: Pull complete
Digest: sha256:184e5f35598e333bfa7de10d8fb1cebb5ee4df5bc0f970bf2b1e7c7345136426
Status: Downloaded newer image for centos:latest
---> 1e1148e4cc2c
Step 4/4 : RUN touch ~/centos.txt
---> Running in c46c76e02eca
Removing intermediate container c46c76e02eca
---> ef6c384fa716
Successfully built ef6c384fa716 |
984bbaa
to
a0ba8c8
Compare
I've had to change this to WIP until openshift/imagebuilder#121 is merged and then I can vendor it here. Test should fail until that happens as the new ThroughTarget() function is not yet available. |
Signed-off-by: TomSweeneyRedHat <[email protected]> Add the --target option to the bud command. This allows the user to specify the last stage to build in a multi stage Dockerfile. Addresses containers#632 Tests: ``` cat ./bud/target/Dockerfile FROM ubuntu:latest RUN touch /1 FROM alpine:latest AS mytarget RUN touch /2 FROM busybox:latest AS mytarget2 RUN touch /3 buildah bud --debug=false -t tom --target mytarget ./bud/target . STEP 1: FROM ubuntu:latest STEP 2: RUN touch /1 STEP 3: FROM alpine:latest AS mytarget STEP 4: RUN touch /2 STEP 5: COMMIT containers-storage:[overlay@/var/lib/containers/storage+/var/run/containers/storage]localhost/tom:latest Getting image source signatures Skipping blob 503e53e365f3 (already present): 5.52 MiB / 5.52 MiB [=========] 0s Copying blob 66e5f29a7649: 3.50 KiB / 3.50 KiB [============================] 0s Copying config e72f1fa3d72d: 704 B / 704 B [================================] 0s Writing manifest to image destination Storing signatures --> e72f1fa3d72ddd3f23acb22a059ecce33dad571433223389e3ce92a5fd9ebae5 STEP 6: COMMIT containers-storage:[overlay@/var/lib/containers/storage+/var/run/containers/storage]localhost/tom:latest Getting image source signatures Skipping blob 503e53e365f3 (already present): 5.52 MiB / 5.52 MiB [=========] 0s Skipping blob 66e5f29a7649 (already present): 3.50 KiB / 3.50 KiB [=========] 0s Copying config e72620d8efe7: 704 B / 704 B [================================] 0s Writing manifest to image destination Storing signatures --> e72620d8efe764178d1352dfb3a9a773794309ee9e879e17d3803b18553f5025 buildah images IMAGE NAME IMAGE TAG IMAGE ID CREATED AT SIZE docker.io/library/ubuntu latest 20bb25d32758 Jan 22, 2019 17:41 90 MB docker.io/library/alpine latest caf27325b298 Jan 30, 2019 17:19 5.8 MB localhost/tom latest 993ee7ded616 Feb 5, 2019 13:49 5.8 MB ``` Signed-off-by: TomSweeneyRedHat <[email protected]>
a0ba8c8
to
dd54096
Compare
Since the last push, I've updated the vendor for imagebuilder and made one small change in wording in the man page. Fingers crossed, this is gtg once the tests pass. |
I will leave this to @vrothberg to approve. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @TomSweeneyRedHat!
📌 Commit dd54096 has been approved by |
⚡ Test exempted: pull fully rebased and already tested. |
Signed-off-by: TomSweeneyRedHat [email protected]
Add the --target option to the bud command. This allows the
user to specify the last stage to build in a multi stage
Dockerfile.
Addresses #632
Tests:
Signed-off-by: TomSweeneyRedHat [email protected]