Skip to content

Commit 56a3648

Browse files
authored
ci: add arm64 docker builds (#63)
1 parent 5a50d7d commit 56a3648

File tree

3 files changed

+108
-76
lines changed

3 files changed

+108
-76
lines changed

.github/workflows/cd-image.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Publish nilchaind to GHCR
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: read
15+
packages: write # Required to push to GHCR
16+
17+
jobs:
18+
build-and-push-arch:
19+
runs-on: ${{ matrix.runner }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
include:
24+
- arch: amd64
25+
platform: linux/amd64
26+
runner: ubuntu-latest
27+
- arch: arm64
28+
platform: linux/arm64
29+
runner: ubuntu-24.04-arm
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Log in to GitHub Container Registry
37+
uses: docker/login-action@v3
38+
with:
39+
registry: ghcr.io
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Set up Docker Buildx
44+
uses: docker/setup-buildx-action@v3
45+
46+
- name: Extract metadata for version
47+
id: meta_tag
48+
uses: docker/metadata-action@v5
49+
with:
50+
images: ghcr.io/nillionnetwork/nilchaind
51+
tags: |
52+
type=ref,event=branch
53+
type=ref,event=tag
54+
type=sha,prefix=
55+
flavor: |
56+
latest=false
57+
58+
- name: Build and push arch-specific image
59+
uses: docker/build-push-action@v6
60+
with:
61+
context: .
62+
platforms: ${{ matrix.platform }}
63+
push: true
64+
tags: ghcr.io/nillionnetwork/nilchaind:${{ github.sha }}-${{ matrix.arch }}
65+
build-args: |
66+
VERSION=${{ steps.meta_tag.outputs.version }}
67+
cache-from: type=gha
68+
cache-to: type=gha,mode=max
69+
provenance: false
70+
71+
create-and-push-manifest:
72+
runs-on: ubuntu-latest
73+
needs: build-and-push-arch
74+
steps:
75+
- name: Log in to GitHub Container Registry
76+
uses: docker/login-action@v3
77+
with:
78+
registry: ghcr.io
79+
username: ${{ github.actor }}
80+
password: ${{ secrets.GITHUB_TOKEN }}
81+
82+
- name: Extract final tags
83+
id: meta
84+
uses: docker/metadata-action@v5
85+
with:
86+
images: ghcr.io/nillionnetwork/nilchaind
87+
tags: |
88+
type=ref,event=branch
89+
type=ref,event=tag
90+
flavor: |
91+
latest=false
92+
93+
- name: Create and push multi-arch manifest
94+
run: |
95+
echo "${{ steps.meta.outputs.tags }}" > tags.txt
96+
97+
while IFS= read -r tag; do
98+
if [ -n "$tag" ]; then
99+
echo "Creating and pushing manifest for tag: $tag"
100+
101+
docker manifest create "$tag" \
102+
ghcr.io/nillionnetwork/nilchaind:${{ github.sha }}-amd64 \
103+
ghcr.io/nillionnetwork/nilchaind:${{ github.sha }}-arm64
104+
105+
docker manifest push "$tag"
106+
fi
107+
done < tags.txt

.github/workflows/docker.yml

Lines changed: 0 additions & 75 deletions
This file was deleted.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22-alpine3.18 as builder
1+
FROM golang:1.22-alpine3.18 AS builder
22

33
RUN set -eux; apk add --no-cache git libusb-dev linux-headers gcc musl-dev make;
44

0 commit comments

Comments
 (0)