Skip to content

Commit c3a2aef

Browse files
authored
feat: refactor Docker builds to use native ARM64 runners with Determinate Nix (#25)
* feat: refactor Docker build to use native ARM64 runners with Determinate Nix Key improvements: - Use GitHub's native ARM64 runners (ubuntu-24.04-arm) for public repos - Replace Docker-in-Docker Nix builds with Determinate Systems installer - Add Magic Nix Cache for blazing fast rebuilds - Simplify Dockerfile by using pre-built binaries - Add .dockerignore for faster context uploads - Create matrix build strategy for parallel AMD64/ARM64 builds - Generate multi-arch manifest from individual arch images Expected benefits: - 5-7x faster build times (native ARM64 vs QEMU emulation) - Parallel execution instead of sequential builds - Better resource utilization with Magic Nix Cache - Elimination of Docker-in-Docker overhead * feat: refactor release workflow to use native ARM64 builds Key improvements: - Split release into three jobs: prepare-release, build (matrix), manifest - Use native ARM64 runners (ubuntu-24.04-arm) for ARM64 builds - Replace QEMU emulation with Determinate Nix installer + Magic Cache - Parallel AMD64/ARM64 builds instead of sequential - Maintain all existing release functionality (version bumping, branches, changelog, GitHub releases) - Create multi-arch manifests from individual architecture images Expected benefits: - 5-7x faster release builds (native vs QEMU) - Parallel execution of AMD64/ARM64 builds - Magic Nix Cache for faster subsequent releases - Better resource utilization with native compilation * fix: improve release changelog generation Key improvements: - Generate changelog BEFORE version bump commit to exclude it - Categorize commits by type (feat, fix, docs, refactor, chore, other) - Filter out noise (version bumps, merges, release commits) - Use emoji categories for better readability - Pass changelog from prepare-release to manifest job - Ensure meaningful changes are highlighted in releases This ensures releases contain useful information about actual changes rather than just the version bump commit message. * feat: add branch testing support to release workflow Key improvements: - Detect if running on main branch vs feature branch - On branches: show release preview in step summary (no actual release) - On main: create actual GitHub release and merge branches - Prevent version bumps, branch creation, and commits when testing - Add comprehensive test summaries for branch runs - Safe testing without side effects This allows testing the complete release workflow including: - Version calculation - Changelog generation - Docker builds and manifest creation - Release notes preview Without creating actual releases or modifying repository. * style: apply pre-commit formatting fixes - Fix Nix formatting with alejandra - Fix YAML formatting with yamlfmt - Ensure all files comply with project style guidelines These changes were automatically applied by pre-commit hooks.
1 parent 6c2a741 commit c3a2aef

File tree

10 files changed

+388
-146
lines changed

10 files changed

+388
-146
lines changed

.github/workflows/buildx.yaml

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@ env:
1010

1111
jobs:
1212
build:
13-
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
include:
16+
- arch: amd64
17+
runner: ubuntu-latest
18+
platform: linux/amd64
19+
- arch: arm64
20+
runner: ubuntu-24.04-arm
21+
platform: linux/arm64
22+
23+
runs-on: ${{ matrix.runner }}
1424
permissions:
1525
contents: read
1626
packages: write
@@ -19,8 +29,15 @@ jobs:
1929
- name: Checkout repository
2030
uses: actions/checkout@v4
2131

22-
- name: Set up QEMU
23-
uses: docker/setup-qemu-action@v3
32+
- name: Install Nix with Determinate Systems installer
33+
uses: DeterminateSystems/nix-installer-action@main
34+
35+
- name: Run the Magic Nix Cache
36+
uses: DeterminateSystems/magic-nix-cache-action@main
37+
38+
- name: Build operator with Nix
39+
run: |
40+
nix build --print-build-logs
2441
2542
- name: Set up Docker Buildx
2643
uses: docker/setup-buildx-action@v3
@@ -38,9 +55,9 @@ jobs:
3855
VERSION=$(grep '^version = ' operator/Cargo.toml | sed 's/version = "\(.*\)"/\1/')
3956
4057
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
41-
TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}"
58+
TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-${{ matrix.arch }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}-${{ matrix.arch }}"
4259
else
43-
TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}-$(git rev-parse --short HEAD)"
60+
TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}-$(git rev-parse --short HEAD)-${{ matrix.arch }}"
4461
fi
4562
4663
echo "tags=$TAGS" >> $GITHUB_OUTPUT
@@ -50,8 +67,45 @@ jobs:
5067
with:
5168
context: ./operator
5269
file: ./operator/docker/Dockerfile
53-
platforms: linux/amd64,linux/arm64
70+
platforms: ${{ matrix.platform }}
5471
push: true
5572
tags: ${{ steps.tags.outputs.tags }}
56-
cache-from: type=gha
57-
cache-to: type=gha,mode=max
73+
cache-from: type=gha,scope=${{ matrix.arch }}
74+
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
75+
build-contexts: |
76+
nix-result=result
77+
78+
manifest:
79+
needs: build
80+
runs-on: ubuntu-latest
81+
permissions:
82+
contents: read
83+
packages: write
84+
steps:
85+
- name: Checkout repository
86+
uses: actions/checkout@v4
87+
88+
- name: Log in to Container Registry
89+
uses: docker/login-action@v3
90+
with:
91+
registry: ${{ env.REGISTRY }}
92+
username: ${{ github.actor }}
93+
password: ${{ secrets.GITHUB_TOKEN }}
94+
95+
- name: Create and push multi-arch manifest
96+
run: |
97+
VERSION=$(grep '^version = ' operator/Cargo.toml | sed 's/version = "\(.*\)"/\1/')
98+
99+
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
100+
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
101+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-amd64 \
102+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-arm64
103+
104+
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION} \
105+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}-amd64 \
106+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}-arm64
107+
else
108+
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}-$(git rev-parse --short HEAD) \
109+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}-$(git rev-parse --short HEAD)-amd64 \
110+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}-$(git rev-parse --short HEAD)-arm64
111+
fi

0 commit comments

Comments
 (0)