I have setup cache actions, and I can see the blob cache in /tmp/ respective.
however, after the jobs completed, the container “GITEA-ACTIONS-TASK-xxxx” (which I found the blob cache in /tmp/xxxx) will gone.
My question is, how to setup the cache (docker layer) persistent for next time use?
Thank you.
name: Build and release container
run-name: ${{ gitea.actor }} build
on:
schedule:
- cron: "0 3 * * 7" # Every sunday at 03:00
push:
branches:
- main
- master
- CICI
paths-ignore:
- .git*
#- .gitea/workflows/*
jobs:
release:
runs-on: [ amd64, qemu ]
container: ${{ secrets.DOCKER_REPO }}/actbuildx:latest
env: |
ACTIONS_RUNTIME_TOKEN: ''
steps:
- name: Checkout
uses: https://github.com/actions/checkout@v3
- name: Set RELEASE_DATE
run: |
echo "RELEASE_DATE=$(date --rfc-3339=date)" >> ${GITHUB_ENV}
- name: Set up QEMU
uses: https://github.com/docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: https://github.com/actions/cache@v3
with:
path: |
/tmp/.buildx-cache.bookworm
/tmp/.buildx-cache.latest
key: ${{ runner.os }}-buildx-${{ gitea.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to registry
uses: https://github.com/docker/login-action@v2
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker AMD64/ARM64 image for latest
if: github.ref == 'refs/heads/main'
uses: https://github.com/docker/build-push-action@v4
with:
context: .
file: Dockerfile
platforms: linux/amd64, linux/arm64
push: true
tags: |
${{ secrets.DOCKER_REPO }}/vbox:latest
${{ secrets.DOCKER_REPO }}/vbox:${{ env.RELEASE_DATE }}
cache-from: type=local,src=/tmp/.buildx-cache.latest
cache-to: type=local,dest=/tmp/.buildx-cache-new.latest
- name: Rotate the cache for latest
run: |
rm -rf /tmp/.buildx-cache.latest
mv /tmp/.buildx-cache-new.latest /tmp/.buildx-cache.latest
- name: Build and push Docker AMD64/ARM64 image for bookworm
if: github.ref == 'refs/heads/main'
uses: https://github.com/docker/build-push-action@v4
with:
context: .
file: Dockerfile.bookworm
platforms: linux/amd64, linux/arm64
push: true
tags: |
${{ secrets.DOCKER_REPO }}/vbox:bookworm
${{ secrets.DOCKER_REPO }}/vbox:bookworm-${{ env.RELEASE_DATE }}
cache-from: type=local,src=/tmp/.buildx-cache.bookworm
cache-to: type=local,dest=/tmp/.buildx-cache-new.bookworm
- name: Rotate the cache for bookworm
run: |
rm -rf /tmp/.buildx-cache.bookworm
mv /tmp/.buildx-cache-new.bookworm /tmp/.buildx-cache.bookworm