Bug 1843405 - Dockerfile builds ignore preamble build args
Summary: Dockerfile builds ignore preamble build args
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build
Version: 4.4
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 4.5.z
Assignee: Nalin Dahyabhai
QA Contact: wewang
URL:
Whiteboard:
Depends On: 1842982
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-06-03 09:02 UTC by OpenShift BugZilla Robot
Modified: 2020-08-10 13:50 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Previously, if a Dockerfile used in Docker strategy builds used the ARG instruction to define build arguments before the first FROM instruction occurred in the Dockerfile, that instruction would be dropped when the Dockerfile was preprocessed to incorporate any overrides which might have been specified in the Build or BuildConfig. References to those arguments would subsequently not be resolved properly while building an image using the preprocessed Dockerfile. The preprocessing logic has been modified so that it preserves ARG instructions which are encountered before the first FROM instruction when generating the updated Dockerfile contents, so this problem should no longer occur.
Clone Of:
Environment:
Last Closed: 2020-08-10 13:50:20 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Github openshift builder pull 156 None closed [release-4.5] Bug 1843405: preserve ARG values that come before the first FROM 2020-08-06 20:53:46 UTC
Red Hat Product Errata RHBA-2020:3188 None None None 2020-08-10 13:50:43 UTC

Description OpenShift BugZilla Robot 2020-06-03 09:02:39 UTC
+++ This bug was initially created as a clone of Bug #1842982 +++

Description of problem:

If a Dockerfile used in Docker strategy builds has build args that precede the first FROM statement, the build arg is dropped from the generated Dockerfile.


Version-Release number of selected component (if applicable): 4.4


How reproducible: Always


Steps to Reproduce:
1. Create a Docker strategy build with a BuildConfig that has ARG instructions that precede the first FROM statement:

```
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
  name: dropped-build-arg
spec:
  source:
    dockerfile: |-
      ARG foo=centos
      FROM registry.redhat.io/ubi8/ubi:latest
      RUN echo "hello from ubi!"
      FROM $foo
      RUN echo "hello from $foo"
    type: Dockerfile
  strategy:
    dockerStrategy: {}
    type: Docker

2. Start the build


Actual results:

Build will fail - no such image $foo

Expected results:

Build should succeed.


Additional info:

Comment 6 wewang 2020-07-30 03:09:12 UTC
Now latest payload is 4.5.0-0.nightly-2020-07-29-230326, should wait newer payload with the pr merged.

Comment 7 wewang 2020-07-31 00:37:21 UTC
Verified in version: 
4.5.0-0.nightly-2020-07-30-020337

Steps:
1. Create a bc:
```
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
  name: dropped-build-arg
spec:
  source:
    dockerfile: |-
      ARG foo=centos
      FROM registry.redhat.io/ubi8/ubi:latest
      RUN echo "hello from ubi!"
      FROM $foo
      RUN echo "hello from $foo"
    type: Dockerfile
  strategy:
    dockerStrategy: {}
    type: Docker
```
2. Start build with bc, build complete

Comment 9 errata-xmlrpc 2020-08-10 13:50:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (OpenShift Container Platform 4.5.5 bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:3188


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