Skip to content

Commit

Permalink
ci: Enable reproducible container builds
Browse files Browse the repository at this point in the history
Requires to use the upcoming buildkit release 0.13.0 and a number of
extra parameters to build-push-action.

Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
jan-kiszka committed Feb 27, 2024
1 parent 76e94ad commit 455ed38
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
12 changes: 12 additions & 0 deletions .github/actions/docker-init/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ runs:
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: image=moby/buildkit:v0.13.0-rc2
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
Expand Down Expand Up @@ -43,3 +45,13 @@ runs:
cache-source: var-lib-apt
cache-target: /var/lib/apt
skip-extraction: ${{ steps.cache-var-lib-apt.outputs.cache-hit }}
- name: Set SOURCE_DATE_EPOCH
run: |
echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
shell: bash
- name: Determine Debian tag
run: |
DEBIAN_RELEASE=$(grep -m 1 'ARG DEBIAN_TAG=' Dockerfile | sed 's/.*DEBIAN_TAG=\(.*\)-.*/\1/')
echo "DEBIAN_TAG=$(podman image search --list-tags debian --limit 1000000000 | \
grep "$DEBIAN_RELEASE-.*-slim" | sort -r | head -1 | sed 's/.*[ ]\+//')" >> $GITHUB_ENV
shell: bash
10 changes: 8 additions & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
push: true
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=registry,rewrite-timestamp=true
tags: ghcr.io/siemens/kas/kas
- name: Build kas-isar image
uses: docker/build-push-action@v5
Expand All @@ -44,5 +47,8 @@ jobs:
cache-to: type=gha,mode=max
target: kas-isar
platforms: linux/amd64,linux/arm64
push: true
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=registry,rewrite-timestamp=true
tags: ghcr.io/siemens/kas/kas-isar
20 changes: 16 additions & 4 deletions .github/workflows/next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ jobs:
with:
cache-from: type=gha
cache-to: type=gha,mode=max
load: true
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=docker,rewrite-timestamp=true
tags: ghcr.io/siemens/kas/kas:next
- name: Test kas image
run: |
Expand All @@ -90,15 +93,21 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=registry,rewrite-timestamp=true
tags: ghcr.io/siemens/kas/kas:next
push: true
- name: Build kas-isar image
uses: docker/build-push-action@v5
with:
cache-from: type=gha
cache-to: type=gha,mode=max
target: kas-isar
load: true
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=docker,rewrite-timestamp=true
tags: ghcr.io/siemens/kas/kas-isar:next
- name: Test kas-isar image
run: |
Expand All @@ -111,5 +120,8 @@ jobs:
cache-to: type=gha,mode=max
target: kas-isar
platforms: linux/amd64,linux/arm64
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=registry,rewrite-timestamp=true
tags: ghcr.io/siemens/kas/kas-isar:next
push: true
10 changes: 8 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
push: true
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=registry,rewrite-timestamp=true
tags: |
ghcr.io/siemens/kas/kas
ghcr.io/siemens/kas/kas:${{ env.RELEASE_VERSION }}
Expand All @@ -37,7 +40,10 @@ jobs:
cache-to: type=gha,mode=max
target: kas-isar
platforms: linux/amd64,linux/arm64
push: true
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=registry,rewrite-timestamp=true
tags: |
ghcr.io/siemens/kas/kas-isar
ghcr.io/siemens/kas/kas-isar:${{ env.RELEASE_VERSION }}
Expand Down

0 comments on commit 455ed38

Please sign in to comment.