forked from containers/buildah
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: cleaning cache must not clean lockfiles
Use-cases as shown in below containerfile cleans cache between the builds, in previous commits we have ensured that buildah lockfiles will not be part of user's cache content hence following use-case must paas ``` FROM quay.io/centos/centos:7 ARG WIPE_CACHE RUN --mount=type=cache,target=/cache1,sharing=locked \ --mount=type=cache,target=/cache2 \ set -ex; \ ls -l /cache1; \ if [[ -v WIPE_CACHE ]]; then \ >&2 echo "Wiping cache"; \ find /cache1 -mindepth 1 -delete; \ fi; \ echo "foo" > /cache1/foo.txt; \ ls -l /cache1; \ chmod --recursive g=u /cache1; \ : ; RUN --mount=type=cache,target=/cache1,sharing=locked \ >&2 echo "Never get here" ``` Closes: containers#4342 Signed-off-by: Aditya R <arajan@redhat.com>
- Loading branch information
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM quay.io/centos/centos:7 | ||
|
||
ARG WIPE_CACHE | ||
|
||
COPY file . | ||
|
||
RUN --mount=type=cache,target=/cache1,sharing=locked \ | ||
--mount=type=cache,target=/cache2 \ | ||
set -ex; \ | ||
ls -l /cache1; \ | ||
if [[ -v WIPE_CACHE ]]; then \ | ||
>&2 echo "Wiping cache"; \ | ||
find /cache1 -mindepth 1 -delete; \ | ||
fi; \ | ||
echo "foo" > /cache1/foo.txt; \ | ||
ls -l /cache1; \ | ||
chmod --recursive g=u /cache1; \ | ||
: ; | ||
|
||
# Cache was wiped-out but lock should not hang here: https://github.com/containers/buildah/issues/4342 | ||
RUN --mount=type=cache,target=/cache1,sharing=locked cat file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hello |