Cache builder so we don't have to pull it all the time#2248
Closed
ryanjbaxter wants to merge 1 commit into
Closed
Conversation
wind57
reviewed
Jun 12, 2026
|
|
||
| - name: export pack cache volumes to tar | ||
| shell: bash | ||
| run: | |
Contributor
There was a problem hiding this comment.
may be we should also cache the .launch cache:
CACHE_VOLS=$(docker volume ls --format '{{.Name}}' | grep 'pack-cache.*\.\(build\|launch\)$' || true)
| echo "No pack cache volumes found, skipping save" | ||
| exit 0 | ||
| fi | ||
| mkdir -p /tmp/pack-volumes |
Contributor
There was a problem hiding this comment.
I think we can do spin an alpine image only once per all volumes:
mkdir -p /tmp/pack-volumes
VOLUME_MOUNTS=""
for vol in $CACHE_VOLS; do
echo "Saving pack cache volume: $vol"
VOLUME_MOUNTS="$VOLUME_MOUNTS -v $vol:/in/$vol"
done
# mount all selected Docker cache volumes into one helper container
# loop over them
# compress each one into its own tar.gz file
# place those tar.gz files in /tmp/pack-volumes on the host
# each volume becomes : /tmp/pack-volumes/pack-cache-foo.build.tar.gz on the host
docker run --rm \
$VOLUME_MOUNTS \
-v /tmp/pack-volumes:/out \
alpine sh -c '
for dir in /in/*; do
vol=$(basename "$dir")
tar czf "/out/${vol}.tar.gz" -C "$dir" .
done
'
| key: pack-cache-${{ runner.os }}-noble-java-tiny-0.0.140 | ||
| restore-keys: pack-cache-${{ runner.os }}-noble-java-tiny- | ||
|
|
||
| - name: load pack cache into docker volumes |
Contributor
There was a problem hiding this comment.
- name: load pack cache into docker volumes
shell: bash
if: steps.pack-cache-restore.outputs.cache-hit == 'true'
run: |
if [ -d /tmp/pack-volumes ] && [ "$(ls -A /tmp/pack-volumes/*.tar.gz 2>/dev/null)" ]; then
VOLUME_MOUNTS=""
for f in /tmp/pack-volumes/*.tar.gz; do
vol=$(basename "$f" .tar.gz)
echo "Restoring pack cache volume: $vol"
docker volume create "$vol" 2>/dev/null || true
VOLUME_MOUNTS="$VOLUME_MOUNTS -v $vol:/out/$vol"
done
# iterate over every cached archive file restored from GitHub Actions cache
# strip path and .tar.gz
# extract that archive into the mounted Docker volume director
docker run --rm \
-v /tmp/pack-volumes:/in \
$VOLUME_MOUNTS \
alpine sh -c '
for tar_file in /in/*.tar.gz; do
vol=$(basename "$tar_file" .tar.gz)
tar xzf "$tar_file" -C "/out/$vol"
done
'
else
echo "No pack cache volumes found to restore"
fi
Contributor
|
@ryanjbaxter if you don't have the time, I can pick this up, its a good enhancement. wdyt? |
Contributor
Author
|
Yes that would be great! I am swamped with other things. I am trying to solve the annoying issue where CI builds on github actions fails with the error code 51. I am sure you have seen that. |
Contributor
|
ok, you can close this one then. I started working on it. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.