Bug 1784532

Summary: Document `FROM` replacement behavior in multistage Docker builds
Product: OpenShift Container Platform Reporter: Adam Kaplan <adam.kaplan>
Component: BuildAssignee: Adam Kaplan <adam.kaplan>
Status: CLOSED ERRATA QA Contact: wewang <wewang>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.3.0CC: aos-bugs, scuppett, wzheng
Target Milestone: ---   
Target Release: 4.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: `FROM` replacement in multistage dockerfile builds was not clear Consequence: developers may not understand how OpenShift manipulates the Dockerfile provided to a build Fix: clarified the text in our API and docs. Result: command line and online docs make it clear that the last FROM statement in a Dockerfile is changed if a developer provides a `from:` imagestream in their BuildConfig spec
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-05-04 11:20:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Adam Kaplan 2019-12-17 16:20:56 UTC
Description of problem:

The current documentation provided online and in our CLI (via oc explain) does not indicate how Docker strategy builds will reference an imagetream in a multistage Dockerfile.

Docs and CLI should be updated to indicate that the last `FROM` statement in a multistage Dockerfile will be replaced.

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

Comment 1 Stephen Cuppett 2019-12-17 19:50:03 UTC
Setting to active development branch for investigation (4.4). Clones will be created for prior releases where backports needed, if any.

Comment 3 wewang 2020-02-11 07:42:19 UTC
Verified in 
4.4.0-0.nightly-2020-02-09-193413

Steps:
1. Use bc to create a build 

kind: "BuildConfig"
apiVersion: v1
metadata: 
  name: multi-test
spec:
  source:
    dockerfile: |-
      FROM scratch as test
      USER 1001
      FROM centos:7
      COPY --from=test /usr/bin/curl /test/
      COPY --from=busybox:latest /bin/echo /test/
      COPY --from=busybox:latest /bin/ping /test/
  strategy:
    dockerStrategy:
      from: 
        kind: ImageStreamTag
        name: ruby:2.2
        namespace: openshift

2. Check the build log
[root@wangwen ~]# oc logs -f build/multi-test-1
Replaced Dockerfile FROM image centos:7
Caching blobs under "/var/cache/blobs".
Writing manifest to image destination
Storing signatures
STEP 1: FROM scratch AS test
STEP 2: USER 1001
a4d03bdf8e8d6125b084fefe2c9580ec739efabc29fa6f345e7690ba878c152d
STEP 3: FROM image-registry.openshift-image-registry.svc:5000/openshift/ruby@sha256:xxxx  ###the last `FROM` statement in a multistage Dockerfile is be replaced 
STEP 4: COPY --from=test /usr/bin/curl /test/

Comment 5 errata-xmlrpc 2020-05-04 11:20:24 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, 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:0581