github.com/mgoltzsche/ctnr@v0.7.1-alpha/image/builder/dockerfile/testfiles/60-multistage.test (about)

     1  FROM alpine:3.7
     2  
     3  FROM alpine:3.7 AS base
     4  WORKDIR /etc
     5  RUN printf '#!/bin/sh\necho hello from script\n' > script.sh && chmod 744 script.sh
     6  
     7  FROM alpine:3.7
     8  
     9  FROM alpine:3.7 AS build
    10  COPY --from=base etc/script.sh script-copy.sh
    11  ENV BASEVAR=baseenvval
    12  ARG BASEARG=baseargval
    13  RUN [ "$(pwd)" = / ] || ("echo WORKDIR has been inherited from previous stage: ($(pwd))"; false)
    14  
    15  FROM scratch AS slim
    16  COPY --from=2 /bin/busybox /bin/
    17  COPY --from=2 /lib/*musl* /lib/
    18  ENTRYPOINT ["/bin/busybox"]
    19  WORKDIR /bin
    20  COPY --from=build script-copy.sh script-copy-copy.sh
    21  
    22  # Assert file system
    23  RUN ["/bin/busybox", "sh", "-c", "[ ! -d /var ] || (ls -la /; false)"]
    24  RUN ["/bin/busybox", "sh", "/bin/script-copy-copy.sh"]
    25  # Assert ENV/VAR scope: BASEENV and BASEARG should not be inherited
    26  RUN ["/bin/busybox", "sh", "-c", "[ ! \"$BASEVAR\" ] || (echo BASEVAR should not be set but is: \"$BASEVAR\"; false)"]
    27  RUN ["/bin/busybox", "sh", "-c", "[ ! \"$BASEARG\" ] || (echo BASEARG should not be set but is: \"$BASEARG\"; false)"]
    28  
    29  FROM base
    30  RUN [ -f /etc/script.sh ] || (echo not inherited from base; false)
    31  
    32  # ASSERT CFG /config/Env/BASEVAR=
    33  # ASSERT STG slim