build image three times, once to push to docker, twice to push caches… #3
Workflow file for this run
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
name: Test Docker Cache | |
on: push | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Prepare | |
id: prep | |
run: | | |
DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPOSITORY#*/} | |
echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build both platforms | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
build-args: INSTALL_DEV=true | |
push: false | |
cache-from: | | |
type=registry,ref=${{ steps.prep.outputs.docker_image }}:buildcache-amd64 | |
type=registry,ref=${{ steps.prep.outputs.docker_image }}:buildcache-arm64 | |
- name: Cache linux/amd64 to registry | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/amd64 | |
build-args: INSTALL_DEV=true | |
push: false | |
cache-from: type=registry,ref=${{ steps.prep.outputs.docker_image }}:buildcache-amd64 | |
cache-to: type=registry,ref=${{ steps.prep.outputs.docker_image }}:buildcache-amd64,mode=max | |
- name: Cache linux/arm64 to registry | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/arm64 | |
build-args: INSTALL_DEV=true | |
push: false | |
cache-from: type=registry,ref=${{ steps.prep.outputs.docker_image }}:buildcache-arm64 | |
cache-to: type=registry,ref=${{ steps.prep.outputs.docker_image }}:buildcache-arm64,mode=max |