Skip to content

Commit

Permalink
Use Docker cache
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Jul 3, 2024
1 parent 6a8f0a1 commit c2419d8
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions .github/workflows/docker-build-test-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ name: Build and test a new image, upload it as artifact
env:
OWNER: ${{ github.repository_owner }}
FORCE_COLOR: 1
BUILDKIT_PROGRESS: plain

on:
workflow_call:
Expand Down Expand Up @@ -38,23 +39,32 @@ jobs:
# Also, they might have running or stopped containers,
# which are not cleaned up by `docker system prun`
- name: Reset docker state and cleanup artifacts 🗑️
if: ${{ startsWith(inputs.runsOn, 'ubuntu') }}
if: ${{ ! startsWith(inputs.runsOn, 'ubuntu') }}
run: |
docker kill $(docker ps --quiet) || true
docker rm $(docker ps --all --quiet) || true
docker system prune --all --force
rm -rf /tmp/aiidalab/
shell: bash

- name: Build image 🛠
working-directory: docker
run: docker buildx bake --set qe.platform=linux/${{ inputs.architecture }} -f docker-bake.hcl -f build.json --load
env:
# Use buildx
DOCKER_BUILDKIT: 1
# Full logs for CI build
BUILDKIT_PROGRESS: plain
shell: bash
- name: Set up Docker Buildx
if: ${{ startsWith(inputs.runsOn, 'ubuntu') }}
uses: docker/setup-buildx-action@v3

- name: Build and load to Docker
id: build-upload
uses: docker/bake-action@v5
with:
# Load locally into Docker for testing
load: true
workdir: docker/
set: |
*.platform=linux/${{ inputs.architecture }}
*.cache-to=type=gha,scope=${{ github.workflow }},mode=max
*.cache-from=type=gha,scope=${{ github.workflow }}
files: |
docker-bake.hcl
build.json
- name: Save image as a tar for later use 💾
run: |
Expand All @@ -63,7 +73,7 @@ jobs:
shell: bash
if: ${{ !github.event.pull_request.head.repo.fork }}

- name: Upload image as artifact 💾
- name: Upload image as artifact 📤
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.image }}-${{ inputs.architecture }}
Expand Down

0 comments on commit c2419d8

Please sign in to comment.