-
Notifications
You must be signed in to change notification settings - Fork 792
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
Allow --build-arg to override FROM in Dockerfile #2404
Comments
Interested in opening a PR to make this happen? |
negative. My Golang is.... nonexistent. I saw that Kaniko does indeed have this functionality. I'm going to give the kaniko ClusterTask a shot. |
No problem, we will take a look at it. |
You can already do this:
to swap out the FROM, build it like |
Also we have a preprocessor built into Buildah and Podman build. Basically you can add ifthenendif
|
@TomSweeneyRedHat Did we ever blog on this feature? |
If not this entire issue would make for a nice blog. |
@rhatdan, I don't believe we did. I'll add it to the list. |
Thanks for the help folks. This is good news, except i dont have access to change the Dockerfile. Basically, i'm inserting a custom layer on top of ubi8 image, and then using tekton to build a custom s2i chain on top of the customized base. That being said, i wont be able to change your Dockerfile for core/base/python36/node10 etc.... To do this, i would have to fork it and that is not an option as i dont want to maintain a separate code base for each runtime just to insert some ARG into the Dockerfile. I request that this be option be like Kanikos where you dont have to edit the Dockerfile to include the FROM arg before the FROM statement. I'd like it better if the only thing i had to do is patch the ClusterTask to include an extra arg (--build-arg). |
It's also worth noting that i've been doing this custom s2i chain builds with basic Openshift build objects for awhile now. 'oc new-build' has this functionality as i'm able to override the FROM image with a '-i' in the oc CLI. I want to port this work over to tekton for a customer and that's why i'm doing this now. |
Ok I am fine with this change. |
Getting a PR would make it faster. |
@ashley-cui PTAL |
Actually I think this is tied in with the one that I'm working on now. I think the fix for #2496 will fit here too. Let me steal this back. |
When an argument was passed into "COPY --from" command in a Containerfile like COPY --from=${toolchainname} The argument was never resolved to the value that it had been set to. Addresses: containers#2496 It may also address containers#2404 but I've not yet tested. Signed-off-by: TomSweeneyRedHat <[email protected]>
When an argument was passed into "COPY --from" command in a Containerfile like COPY --from=${toolchainname} The argument was never resolved to the value that it had been set to. Addresses: containers#2496 It may also address containers#2404 but I've not yet tested. Signed-off-by: TomSweeneyRedHat <[email protected]>
When an argument was passed into "COPY --from" command in a Containerfile like COPY --from=${toolchainname} The argument was never resolved to the value that it had been set to. Addresses: containers#2496 It may also address containers#2404 but I've not yet tested. Signed-off-by: TomSweeneyRedHat <[email protected]>
2522: Handle COPY --from when an argument is used r=rhatdan a=TomSweeneyRedHat When an argument was passed into "COPY --from" command in a Containerfile like COPY --from=${toolchainname} The argument was never resolved to the value that it had been set to. Addresses: #2496 It may also address #2404 but I've not yet tested. Signed-off-by: TomSweeneyRedHat <[email protected]> <!-- Thanks for sending a pull request! Please make sure you've read and understood our contributing guidelines (https://github.com/containers/buildah/blob/master/CONTRIBUTING.md) as well as ensuring that all your commits are signed with `git commit -s`. --> #### What type of PR is this? <!-- Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request. Uncomment only one `/kind <>` line, hit enter to put that in a new line, and remove leading whitespace from that line: --> > /kind api-change > /kind bug > /kind cleanup > /kind deprecation > /kind design > /kind documentation > /kind failing-test > /kind feature > /kind flake > /kind other #### What this PR does / why we need it: #### How to verify it #### Which issue(s) this PR fixes: <!-- Automatically closes linked issue when PR is merged. Uncomment the following comment block and include the issue number or None on one line. Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`, or `None`. --> <!-- Fixes # or None --> #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? <!-- If no, just write `None` in the release-note block below. If yes, a release note is required: Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required". For more information on release notes please follow the kubernetes model: https://git.k8s.io/community/contributors/guide/release-notes.md --> ```release-note ``` Co-authored-by: TomSweeneyRedHat <[email protected]>
Hey Tom, Would love to help you test this. Where can i get the latest buildah image from so i can see if this works now? |
Nick, there's no ready made rpm at the moment. So there are two choices, A) you could clone the repo and build from upstream, or B) you could use Podman and run the quay.io/bulidah/upstream:latest image. I just updated that container image on quay.io a little bit ago, so it should have the latest/greatest there. |
Hey Tom, I dont think quay.io/bulidah/upstream:latest is a valid image. Or at least, not one that i have privs too see. EDIT |
I'm setting this in my buildah ClusterTask:
And the image URL is being populated during the Pipeline Run. But, buildah is ignoring the FROM build-arg and using the FROM in the Dockerfile. Any pointers on how to use this properly? I'm using this buildah image 'quay.io/buildah/upstream:master' Output from PipelineRun
|
@nnachefski for this latest error, were you using the same Dockerfile that you included in an earlier comment in this thread? We've had some issues with ARG handling in Containerfiles when an equal sign was in the mix. As a real quick try, can you drop the first equal sign? i.e. and try that. It's way past open eyelid time here, I'll check back in the morning. |
@nnachefski @TomSweeneyRedHat What is going on with this one? |
this still doesnt work. |
Using image quay.io/buildah/upstream:master
|
DO NOT MERGE: I need to add tests, but before doing so want to see if I've messed anything up with the CI. This changes will allow the "FROM" statement in a Containerfile to be overriden with a build-arg. If I have this Dockerfile.fedora ``` FROM fedora ``` This command will instead build an alpine image: ``` STEP 1: FROM alpine Completed short name "alpine" with unqualified-search registries (origin: /etc/containers/registries.conf) Getting image source signatures Copying blob 188c0c94c7c5 done Copying config d6e46aa247 done Writing manifest to image destination Storing signatures STEP 2: COMMIT tom --> d6e46aa2470 d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0 ``` Addresses: containers#2404 Signed-off-by: TomSweeneyRedHat <[email protected]>
This changes will allow the "FROM" statement in a Containerfile to be overriden with a build-arg. If I have this Dockerfile.fedora ``` FROM fedora ``` This command will instead build an alpine image: ``` STEP 1: FROM alpine Completed short name "alpine" with unqualified-search registries (origin: /etc/containers/registries.conf) Getting image source signatures Copying blob 188c0c94c7c5 done Copying config d6e46aa247 done Writing manifest to image destination Storing signatures STEP 2: COMMIT tom --> d6e46aa2470 d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0 ``` Addresses: containers#2404 Signed-off-by: TomSweeneyRedHat <[email protected]>
This changes will allow the "FROM" statement in a Containerfile to be overriden with a build-arg. If I have this Dockerfile.fedora ``` FROM fedora ``` This command will instead build an alpine image: ``` STEP 1: FROM alpine Completed short name "alpine" with unqualified-search registries (origin: /etc/containers/registries.conf) Getting image source signatures Copying blob 188c0c94c7c5 done Copying config d6e46aa247 done Writing manifest to image destination Storing signatures STEP 2: COMMIT tom --> d6e46aa2470 d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0 ``` Addresses: containers#2404 Signed-off-by: TomSweeneyRedHat <[email protected]>
This changes will allow the "FROM" statement in a Containerfile to be overriden with a build-arg. If I have this Dockerfile.fedora ``` FROM fedora ``` This command will instead build an alpine image: ``` STEP 1: FROM alpine Completed short name "alpine" with unqualified-search registries (origin: /etc/containers/registries.conf) Getting image source signatures Copying blob 188c0c94c7c5 done Copying config d6e46aa247 done Writing manifest to image destination Storing signatures STEP 2: COMMIT tom --> d6e46aa2470 d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0 ``` Addresses: containers#2404 Signed-off-by: TomSweeneyRedHat <[email protected]>
This changes will allow the "FROM" statement in a Containerfile to be overriden with a build-arg. If I have this Dockerfile.fedora ``` FROM fedora ``` This command will instead build an alpine image: ``` STEP 1: FROM alpine Completed short name "alpine" with unqualified-search registries (origin: /etc/containers/registries.conf) Getting image source signatures Copying blob 188c0c94c7c5 done Copying config d6e46aa247 done Writing manifest to image destination Storing signatures STEP 2: COMMIT tom --> d6e46aa2470 d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0 ``` Addresses: containers#2404 Signed-off-by: TomSweeneyRedHat <[email protected]>
This changes will allow the "FROM" statement in a Containerfile to be overriden with a build-arg. If I have this Dockerfile.fedora ``` FROM fedora ``` This command will instead build an alpine image: ``` STEP 1: FROM alpine Completed short name "alpine" with unqualified-search registries (origin: /etc/containers/registries.conf) Getting image source signatures Copying blob 188c0c94c7c5 done Copying config d6e46aa247 done Writing manifest to image destination Storing signatures STEP 2: COMMIT tom --> d6e46aa2470 d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0 ``` Addresses: containers#2404 Signed-off-by: TomSweeneyRedHat <[email protected]>
This changes will allow the "FROM" statement in a Containerfile to be overriden with a new `--from` flag. If I have this Dockerfile.fedora ``` FROM fedora ``` This command will instead build an alpine image: ``` STEP 1: FROM alpine Completed short name "alpine" with unqualified-search registries (origin: /etc/containers/registries.conf) Getting image source signatures Copying blob 188c0c94c7c5 done Copying config d6e46aa247 done Writing manifest to image destination Storing signatures STEP 2: COMMIT tom --> d6e46aa2470 d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0 ``` Addresses: containers#2404 Signed-off-by: TomSweeneyRedHat <[email protected]>
These changes will allow the "FROM" statement in a Containerfile to be overridden with a new `--from` option. If I have this Dockerfile.fedora ``` FROM fedora ``` This command will instead build an alpine image: ``` STEP 1: FROM alpine Completed short name "alpine" with unqualified-search registries (origin: /etc/containers/registries.conf) Getting image source signatures Copying blob 188c0c94c7c5 done Copying config d6e46aa247 done Writing manifest to image destination Storing signatures STEP 2: COMMIT tom --> d6e46aa2470 d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0 ``` Addresses: containers#2404 Signed-off-by: TomSweeneyRedHat <[email protected]>
These changes will allow the "FROM" statement in a Containerfile to be overridden with a new `--from` option. If I have this Dockerfile.fedora ``` FROM fedora ``` This command will instead build an alpine image: ``` STEP 1: FROM alpine Completed short name "alpine" with unqualified-search registries (origin: /etc/containers/registries.conf) Getting image source signatures Copying blob 188c0c94c7c5 done Copying config d6e46aa247 done Writing manifest to image destination Storing signatures STEP 2: COMMIT tom --> d6e46aa2470 d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0 ``` Addresses: containers#2404 Signed-off-by: TomSweeneyRedHat <[email protected]>
These changes will allow the "FROM" statement in a Containerfile to be overridden with a new `--from` option. If I have this Dockerfile.fedora ``` FROM fedora ``` This command will instead build an alpine image: ``` STEP 1: FROM alpine Completed short name "alpine" with unqualified-search registries (origin: /etc/containers/registries.conf) Getting image source signatures Copying blob 188c0c94c7c5 done Copying config d6e46aa247 done Writing manifest to image destination Storing signatures STEP 2: COMMIT tom --> d6e46aa2470 d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0 ``` Addresses: containers#2404 Signed-off-by: TomSweeneyRedHat <[email protected]>
These changes will allow the "FROM" statement in a Containerfile to be overridden with a new `--from` option. If I have this Dockerfile.fedora ``` FROM fedora ``` This command will instead build an alpine image: ``` STEP 1: FROM alpine Completed short name "alpine" with unqualified-search registries (origin: /etc/containers/registries.conf) Getting image source signatures Copying blob 188c0c94c7c5 done Copying config d6e46aa247 done Writing manifest to image destination Storing signatures STEP 2: COMMIT tom --> d6e46aa2470 d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0 ``` Addresses: containers#2404 Signed-off-by: TomSweeneyRedHat <[email protected]>
These changes will allow the "FROM" statement in a Containerfile to be overridden with a new `--from` option. If I have this Dockerfile.fedora ``` FROM fedora ``` This command will instead build an alpine image: ``` STEP 1: FROM alpine Completed short name "alpine" with unqualified-search registries (origin: /etc/containers/registries.conf) Getting image source signatures Copying blob 188c0c94c7c5 done Copying config d6e46aa247 done Writing manifest to image destination Storing signatures STEP 2: COMMIT tom --> d6e46aa2470 d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0 ``` Addresses: containers#2404 Signed-off-by: TomSweeneyRedHat <[email protected]>
Looks like this was fixed in #2823. Can this be closed now @TomSweeneyRedHat ? |
I would like to be able to over override the FROM image in the Dockerfile from the command line
Example:
The text was updated successfully, but these errors were encountered: