Bug 1802202 - Dockerfile ARG values not handled properly in multistage builds
Summary: Dockerfile ARG values not handled properly in multistage builds
Keywords:
Status: CLOSED DUPLICATE of bug 1839683
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build
Version: 4.4
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 4.5.0
Assignee: Gabe Montero
QA Contact: wewang
URL:
Whiteboard:
Depends On: 1801875 1839683
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-02-12 15:05 UTC by Adam Kaplan
Modified: 2020-07-14 14:00 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-03-13 16:50:46 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Adam Kaplan 2020-02-12 15:05:09 UTC
Splitting out from Bug #1801388

If a multi-stage Dockerfile utilizes build ARGS in FROM statements, these are not correctly processed by buildah.

Steps to Reproduce:

1. Create a BuildConfig as follows:
```
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
  name: sample-build-docker-args-preset
spec:
  source:
    dockerfile: |-
      FROM centos
      ARG foo=centos
      FROM $foo
    type: Dockerfile
  strategy:
    dockerStrategy: {}
    type: Docker
```
2. Start the build

Actual Results:

Build fails with error:
```
I0211 22:06:43.140914       1 builder.go:318] Starting Docker build from build config sample-build-docker-args-preset-17 ...
F0211 22:06:43.209605       1 helpers.go:114] error: build error: error parsing name "$foo": error parsing image name "$foo": invalid reference format
```

Expected results:

Build succeeds

Additional Info:

https://github.com/openshift/builder/pull/130#discussion_r377979342

Comment 1 Gabe Montero 2020-02-12 15:10:58 UTC
I've added a dependency link to https://bugzilla.redhat.com/show_bug.cgi?id=1801875 because at the moment, based on the discussion between Ben, Nalin, and myself, we think
the buildah api's should handle the above scenario without any translations in openshift/builder

Nalin is investigating.

Based on his outcome, we can use this bug to either
a) bump buildah to get the fix
b) make the openshift/builer (via imagebuilder) translations when mutating the Dockerfile before it is passed to buildah

But again, at the moment, option a) is considered the correct approach.

Comment 2 Gabe Montero 2020-02-17 20:12:49 UTC
As this is a tracking bug to react to https://bugzilla.redhat.com/show_bug.cgi?id=1801875 I'm moving this to POST, at least for now.

Comment 3 Gabe Montero 2020-03-13 16:50:46 UTC
As the originator of https://bugzilla.redhat.com/show_bug.cgi?id=1801875 I'll see if/when it progresses and can open any bugs to update openshift/builder buildah dependencies as needed

closing this tracking bug

Comment 4 Adam Kaplan 2020-05-26 12:39:50 UTC

*** This bug has been marked as a duplicate of bug 1839683 ***


Note You need to log in before you can comment on or make changes to this bug.