FROM debian:9.11 as base
COPY . .

FROM scratch as second
ENV foopath context/foo
COPY --from=0 $foopath context/b* /foo/

FROM second as third
COPY --from=base /context/foo /new/foo

FROM base as fourth
# Make sure that we snapshot intermediate images correctly
RUN date > /date
ENV foo bar

# This base image contains symlinks with relative paths to ignored directories
# We need to test they're extracted correctly
FROM fedora@sha256:c4cc32b09c6ae3f1353e7e33a8dda93dc41676b923d6d89afa996b421cc5aa48

FROM fourth
ARG file
COPY --from=second /foo ${file}
COPY --from=debian:9.11 /etc/os-release /new
