Try local Docker image caching in GHA
This commit is contained in:
parent
5576778f09
commit
a1f46060fa
1 changed files with 29 additions and 1 deletions
30
.github/workflows/test.yml
vendored
30
.github/workflows/test.yml
vendored
|
|
@ -58,12 +58,32 @@ jobs:
|
|||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
driver: docker
|
||||
install: true
|
||||
|
||||
# Enable Docker layer caching without having to push to a registry.
|
||||
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#local-cache
|
||||
# This may eventually be migrated to the GitHub Actions cache backend,
|
||||
# which is still considered experimental.
|
||||
# https://github.com/moby/buildkit#github-actions-cache-experimental
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ matrix.platform }}-buildx-${{ github.sha }}
|
||||
restore-keys: ${{ matrix.platform }}-buildx-
|
||||
|
||||
# Use docker buildx instead of docker-compose here because cache exporting
|
||||
# does not seem to work as of docker-compose v2.6.0 and buildx v0.8.2, even
|
||||
# though it works with buildx individually.
|
||||
- name: Build R
|
||||
run: |
|
||||
for version in ${{ env.R_VERSIONS }}; do
|
||||
docker buildx build -t r-builds:${{ matrix.platform }} \
|
||||
--file builder/Dockerfile.${{ matrix.platform }} \
|
||||
--cache-from "type=local,src=/tmp/.buildx-cache" \
|
||||
--cache-to "type=local,dest=/tmp/.buildx-cache-new,mode=max" \
|
||||
--load \
|
||||
builder
|
||||
R_VERSION=$version make build-r-${{ matrix.platform }}
|
||||
done
|
||||
|
||||
|
|
@ -72,3 +92,11 @@ jobs:
|
|||
for version in ${{ env.R_VERSIONS }}; do
|
||||
R_VERSION=$version make test-r-${{ matrix.platform }}
|
||||
done
|
||||
|
||||
# Temporary workaround for unbounded GHA cache growth with the local cache mode.
|
||||
# https://github.com/docker/build-push-action/issues/252
|
||||
# https://github.com/moby/buildkit/issues/1896
|
||||
- name: Move cache
|
||||
run: |
|
||||
rm -rf /tmp/.buildx-cache
|
||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||
|
|
|
|||
Loading…
Reference in a new issue