Skip to content

Commit

Permalink
ci: Enable apt caching for container builds
Browse files Browse the repository at this point in the history
The Dockerfile is already prepared and works locally. Now also make use
of that on github.

Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
jan-kiszka committed Feb 26, 2024
1 parent f65b58f commit dc97b9f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/actions/docker-init/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,27 @@ runs:
registry: ghcr.io
username: ${{ inputs.deploy-user }}
password: ${{ inputs.deploy-token }}
- name: Cache var-cache-apt
id: cache-var-cache-apt
uses: actions/cache@v4
with:
path: var-cache-apt
key: var-cache-apt-${{ hashFiles('Dockerfile') }}
- name: Cache var-lib-apt
id: cache-var-lib-apt
uses: actions/cache@v4
with:
path: var-lib-apt
key: var-lib-apt-${{ hashFiles('Dockerfile') }}
- name: Inject var-cache-apt into docker
uses: reproducible-containers/[email protected]
with:
cache-source: var-cache-apt
cache-target: /var/cache/apt
skip-extraction: ${{ steps.cache-var-cache-apt.outputs.cache-hit }}
- name: Inject var-lib-apt into docker
uses: reproducible-containers/[email protected]
with:
cache-source: var-lib-apt
cache-target: /var/lib/apt
skip-extraction: ${{ steps.cache-var-lib-apt.outputs.cache-hit }}
4 changes: 4 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
push: ${{ env.PUSH_MASTER }}
tags: ghcr.io/siemens/kas/kas
- name: Build kas-isar image
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
target: kas-isar
platforms: linux/amd64,linux/arm64
push: ${{ env.PUSH_MASTER }}
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
load: true
tags: ghcr.io/siemens/kas/kas:next
- name: Test kas image
Expand All @@ -87,13 +89,17 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
tags: ghcr.io/siemens/kas/kas:next
push: true
- name: Build kas-isar image
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
target: kas-isar
load: true
tags: ghcr.io/siemens/kas/kas-isar:next
Expand All @@ -105,6 +111,8 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
target: kas-isar
platforms: linux/amd64,linux/arm64
tags: ghcr.io/siemens/kas/kas-isar:next
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
push: true
tags: |
Expand All @@ -33,6 +35,8 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
target: kas-isar
platforms: linux/amd64,linux/arm64
push: true
Expand Down

0 comments on commit dc97b9f

Please sign in to comment.