Skip to content
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

buildah bud --target functionality missing #632

Closed
TomSweeneyRedHat opened this issue Apr 24, 2018 · 11 comments
Closed

buildah bud --target functionality missing #632

TomSweeneyRedHat opened this issue Apr 24, 2018 · 11 comments

Comments

@TomSweeneyRedHat
Copy link
Member

Description
buildah bud --target is missing and needs to be provided. This is functionality that Docker has.

#599 is the parent issue for this issue.

Output of buildah version:

Buildah v0.16

@rhatdan
Copy link
Member

rhatdan commented Apr 25, 2018

Specifying target build stage (--target)

When building a Dockerfile with multiple build stages, --target can be used to specify an intermediate build stage by name as a final stage for the resulting image. Commands after the target stage will be skipped.

FROM debian AS build-env
...

FROM alpine AS production-env
...

$ docker build -t mybuildimage --target build-env .

@TomSweeneyRedHat TomSweeneyRedHat self-assigned this Jun 23, 2018
@rhatdan
Copy link
Member

rhatdan commented Aug 2, 2018

@TomSweeneyRedHat Now since @umohnani8 has added layers, this should be doable? @umohnani8 WDYT?

@rhatdan
Copy link
Member

rhatdan commented Aug 2, 2018

from docker build docs.

Specifying target build stage (--target)

When building a Dockerfile with multiple build stages, --target can be used to specify an intermediate build stage by name as a final stage for the resulting image. Commands after the target stage will be skipped.

FROM debian AS build-env
...

FROM alpine AS production-env
...

$ docker build -t mybuildimage --target build-env .

@rhatdan
Copy link
Member

rhatdan commented Nov 27, 2018

@TomSweeneyRedHat Do we still have this issue?

@TomSweeneyRedHat
Copy link
Member Author

@rhatdan I think it's now doable with @umohnani8 's changes for layering, but I don't think we've the code in place in the bud command to accept the --target option yet.

@h-vetinari
Copy link

h-vetinari commented Jan 31, 2019

Hitting this issue hard as I need multistage builds with --target, but can't upgrade docker from within RHEL past 1.13, and podman/buildah in the newest RHEL7.6 (or 8beta for that matter), do not yet fully replicate the 1.5year old ability of docker...

Any workaround I could use in the meantime? How can I tag an intermediate layer (you may assume I know how many layers down it is)? And I mean programatically; it does work to manually copy the hash from the right point in the build output and tag it, but I really don't wanna have to regex into that.

@rhatdan
Copy link
Member

rhatdan commented Feb 1, 2019

podman 1.0 and buildah 1.6 should have support for this.

@TomSweeneyRedHat
Copy link
Member Author

@rhatdan I think the code is in place to make this work now, but we don't have the --target option available for use yet.

@rhatdan
Copy link
Member

rhatdan commented Feb 1, 2019

Ok, could you make this happen.

@TomSweeneyRedHat
Copy link
Member Author

yep, I'll bump it up the todo list.

TomSweeneyRedHat added a commit to TomSweeneyRedHat/buildah that referenced this issue Feb 2, 2019
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:
```
FROM fedora:latest
RUN touch /foo

FROM alpine:latest AS mytarget
RUN touch /1

STEP 1: FROM alpine:latest AS mytarget
Getting image source signatures
Copying blob 6c40cc604d8e: 2.63 MiB / 2.63 MiB [============================] 2s
Copying config caf27325b298: 1.48 KiB / 1.48 KiB [==========================] 0s
Writing manifest to image destination
Storing signatures
STEP 2: RUN touch /1
STEP 3: 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 3266af627e70: 3.50 KiB / 3.50 KiB [============================] 0s
Copying config 52c07ff42762: 704 B / 704 B [================================] 0s
Writing manifest to image destination
Storing signatures
--> 52c07ff42762c07286ecb608c342df4af7105190ce30f70b678ff667a26c1842
STEP 4: 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 3266af627e70 (already present): 3.50 KiB / 3.50 KiB [=========] 0s
Copying config c75fd71d1f59: 704 B / 704 B [================================] 0s
Writing manifest to image destination
Storing signatures
--> c75fd71d1f59c500b2009151919b3ee183c0314db9e91f30e348daca6bbaa74b

IMAGE NAME                                               IMAGE TAG            IMAGE ID             CREATED AT             SIZE
docker.io/library/alpine                                 latest               caf27325b298         Jan 30, 2019 17:19     5.8 MB
localhost/tom

```

Signed-off-by: TomSweeneyRedHat <[email protected]>
TomSweeneyRedHat added a commit to TomSweeneyRedHat/buildah that referenced this issue Feb 3, 2019
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:
```
FROM fedora:latest
RUN touch /foo

FROM alpine:latest AS mytarget
RUN touch /1

STEP 1: FROM alpine:latest AS mytarget
Getting image source signatures
Copying blob 6c40cc604d8e: 2.63 MiB / 2.63 MiB [============================] 2s
Copying config caf27325b298: 1.48 KiB / 1.48 KiB [==========================] 0s
Writing manifest to image destination
Storing signatures
STEP 2: RUN touch /1
STEP 3: 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 3266af627e70: 3.50 KiB / 3.50 KiB [============================] 0s
Copying config 52c07ff42762: 704 B / 704 B [================================] 0s
Writing manifest to image destination
Storing signatures
--> 52c07ff42762c07286ecb608c342df4af7105190ce30f70b678ff667a26c1842
STEP 4: 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 3266af627e70 (already present): 3.50 KiB / 3.50 KiB [=========] 0s
Copying config c75fd71d1f59: 704 B / 704 B [================================] 0s
Writing manifest to image destination
Storing signatures
--> c75fd71d1f59c500b2009151919b3ee183c0314db9e91f30e348daca6bbaa74b

IMAGE NAME                                               IMAGE TAG            IMAGE ID             CREATED AT             SIZE
docker.io/library/alpine                                 latest               caf27325b298         Jan 30, 2019 17:19     5.8 MB
localhost/tom

```

Signed-off-by: TomSweeneyRedHat <[email protected]>
TomSweeneyRedHat added a commit to TomSweeneyRedHat/buildah that referenced this issue Feb 4, 2019
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:
```
FROM fedora:latest
RUN touch /foo

FROM alpine:latest AS mytarget
RUN touch /1

STEP 1: FROM alpine:latest AS mytarget
Getting image source signatures
Copying blob 6c40cc604d8e: 2.63 MiB / 2.63 MiB [============================] 2s
Copying config caf27325b298: 1.48 KiB / 1.48 KiB [==========================] 0s
Writing manifest to image destination
Storing signatures
STEP 2: RUN touch /1
STEP 3: 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 3266af627e70: 3.50 KiB / 3.50 KiB [============================] 0s
Copying config 52c07ff42762: 704 B / 704 B [================================] 0s
Writing manifest to image destination
Storing signatures
--> 52c07ff42762c07286ecb608c342df4af7105190ce30f70b678ff667a26c1842
STEP 4: 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 3266af627e70 (already present): 3.50 KiB / 3.50 KiB [=========] 0s
Copying config c75fd71d1f59: 704 B / 704 B [================================] 0s
Writing manifest to image destination
Storing signatures
--> c75fd71d1f59c500b2009151919b3ee183c0314db9e91f30e348daca6bbaa74b

IMAGE NAME                                               IMAGE TAG            IMAGE ID             CREATED AT             SIZE
docker.io/library/alpine                                 latest               caf27325b298         Jan 30, 2019 17:19     5.8 MB
localhost/tom

```

Signed-off-by: TomSweeneyRedHat <[email protected]>
TomSweeneyRedHat added a commit to TomSweeneyRedHat/buildah that referenced this issue Feb 4, 2019
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:
```
FROM fedora:latest
RUN touch /foo

FROM alpine:latest AS mytarget
RUN touch /1

STEP 1: FROM alpine:latest AS mytarget
Getting image source signatures
Copying blob 6c40cc604d8e: 2.63 MiB / 2.63 MiB [============================] 2s
Copying config caf27325b298: 1.48 KiB / 1.48 KiB [==========================] 0s
Writing manifest to image destination
Storing signatures
STEP 2: RUN touch /1
STEP 3: 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 3266af627e70: 3.50 KiB / 3.50 KiB [============================] 0s
Copying config 52c07ff42762: 704 B / 704 B [================================] 0s
Writing manifest to image destination
Storing signatures
--> 52c07ff42762c07286ecb608c342df4af7105190ce30f70b678ff667a26c1842
STEP 4: 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 3266af627e70 (already present): 3.50 KiB / 3.50 KiB [=========] 0s
Copying config c75fd71d1f59: 704 B / 704 B [================================] 0s
Writing manifest to image destination
Storing signatures
--> c75fd71d1f59c500b2009151919b3ee183c0314db9e91f30e348daca6bbaa74b

IMAGE NAME                                               IMAGE TAG            IMAGE ID             CREATED AT             SIZE
docker.io/library/alpine                                 latest               caf27325b298         Jan 30, 2019 17:19     5.8 MB
localhost/tom

```

Signed-off-by: TomSweeneyRedHat <[email protected]>
TomSweeneyRedHat added a commit to TomSweeneyRedHat/buildah that referenced this issue Feb 5, 2019
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]>
TomSweeneyRedHat added a commit to TomSweeneyRedHat/buildah that referenced this issue Feb 12, 2019
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]>
rh-atomic-bot pushed a commit that referenced this issue Feb 13, 2019
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:
```
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]>

Closes: #1321
Approved by: vrothberg
@h-vetinari
Copy link

This issue can probably be closed now? It seems to have made it to 1.7 (at least according to the release notes).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants