🐛 fix: Cache the runner image to reduce build time (#143)

This commit is contained in:
Wanjohi
2024-12-10 18:41:34 +03:00
committed by GitHub
parent 8d6b7f744b
commit a85c10a281
2 changed files with 66 additions and 17 deletions

View File

@@ -41,6 +41,14 @@ jobs:
-
name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
-
name: Build Docker image
uses: docker/build-push-action@v5
@@ -49,7 +57,14 @@ jobs:
context: ./
push: false
load: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
tags: nestri:runner
-
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build-docker-main:
name: Build image on main
@@ -83,6 +98,14 @@ jobs:
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
-
name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
-
name: Build Docker image
uses: docker/build-push-action@v5
@@ -90,5 +113,12 @@ jobs:
file: containers/runner.Containerfile
context: ./
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
-
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache