Fix .dockerignore for build context copies in later stages (#1447)

* Extend .dockerignore integration test with copies in later stages

.dockerignore should continue to apply when copying from the build context in later stages, but it currently doesn't

* Replace excluded global with passed along FileContext struct

This new FileContext struct allows much cleaner handling of context specific file exclusions.
The global excluded file state is no longer needed.

Additionally this also fixes the issue where excluded files aren't being applied for build context copies in later build stages.
This commit is contained in:
Tinjo Schöni
2020-10-08 12:47:14 -07:00
committed by GitHub
parent 0ef3a6b525
commit 5f4e2f1366
14 changed files with 150 additions and 126 deletions
@@ -7,5 +7,13 @@ COPY ignore/* /foo
From base as first
COPY --from=base /foo ignore/bar
FROM first
COPY --from=first ignore/* /fooAnother/
# Make sure that .dockerignore also applies for later stages
FROM scratch as base2
COPY ignore/* /foo
From base2 as second
COPY --from=base2 /foo ignore/bar
FROM scratch
COPY --from=first ignore/* /fooAnother/
COPY --from=second ignore/* /fooAnother2/