Skip to content

Commit 09a1b19

Browse files
feat: Multiarch images (#58)
1 parent 95424c4 commit 09a1b19

File tree

2 files changed

+86
-15
lines changed

2 files changed

+86
-15
lines changed

.github/image/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM debian:12-slim
2+
3+
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
4+
5+
ARG TARGETARCH
6+
COPY bin/controller-Linux-${TARGETARCH} /bin/controller
7+
RUN chmod +x /bin/controller
8+
RUN ln -s /bin/controller /controller
9+
10+
ENTRYPOINT [ "controller" ]

.github/workflows/controller.yml

Lines changed: 76 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,95 @@ on:
77
paths:
88
- ".github/workflows/controller.yml"
99
- "operator/**"
10-
10+
1111
jobs:
12-
build-images:
12+
build:
13+
continue-on-error: true
14+
1315
strategy:
14-
fail-fast: false
1516
matrix:
1617
include:
17-
- context: operator
18-
file: operator/Dockerfile
19-
endpoint: demeter-run/ext-cardano-dbsync-serverless
18+
- release_for: Linux-x86_64
19+
build_on: ubuntu-22.04
20+
target: x86_64-unknown-linux-gnu
21+
args: "--locked --release"
2022

21-
continue-on-error: true
23+
- release_for: Linux-arm64
24+
build_on: ubuntu-22.04-arm
25+
target: "aarch64-unknown-linux-gnu"
26+
args: "--locked --release"
27+
28+
runs-on: ${{ matrix.build_on }}
29+
30+
steps:
31+
- name: checkout repository
32+
uses: actions/checkout@v4
33+
34+
- uses: Swatinem/rust-cache@v2
35+
with:
36+
shared-key: "release"
37+
38+
- name: Install stable toolchain
39+
uses: actions-rs/toolchain@v1
40+
with:
41+
toolchain: stable
42+
43+
- name: Run cargo build
44+
uses: actions-rs/cargo@v1
45+
with:
46+
command: build
47+
args: --target ${{ matrix.target }} ${{ matrix.args }}
48+
49+
- name: rename binaries
50+
run: |
51+
mv target/${{ matrix.target }}/release/controller${{ matrix.ext }} controller-${{ matrix.release_for }}${{ matrix.ext }}
52+
53+
- name: upload artifacts
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: binaries-${{ matrix.release_for }}
57+
path: controller-${{ matrix.release_for }}${{ matrix.ext }}
58+
59+
docker:
2260
runs-on: ubuntu-latest
61+
needs: [build]
62+
63+
permissions:
64+
contents: read
65+
packages: write
66+
2367
steps:
24-
- uses: actions/[email protected]
68+
- name: Checkout repository
69+
uses: actions/checkout@v4
70+
71+
- name: Set up Docker Buildx
72+
uses: docker/setup-buildx-action@v3
2573

26-
- name: Login to GitHub Container Registry
27-
uses: docker/login-action@v1
74+
- name: Login to DockerHub
75+
uses: docker/login-action@v3
2876
with:
2977
registry: ghcr.io
3078
username: ${{ github.actor }}
3179
password: ${{ secrets.GITHUB_TOKEN }}
3280

81+
- name: Download artifacts
82+
uses: actions/download-artifact@v4
83+
with:
84+
pattern: binaries-*
85+
merge-multiple: true
86+
path: .github/image/bin
87+
88+
# we need to rename the artifact so that the name matches
89+
# the value that Docker uses for TARGET_ARCH to keep the
90+
# Dockerfile simple
91+
- name: Rename artifacts
92+
run: |+
93+
mv .github/image/bin/controller-Linux-x86_64 .github/image/bin/controller-Linux-amd64
94+
3395
- name: Build and push
34-
uses: docker/build-push-action@v2
96+
uses: docker/build-push-action@v5
3597
with:
36-
context: ${{ matrix.context }}
37-
file: ${{ matrix.file }}
38-
platforms: linux/amd64
98+
context: .github/image
99+
platforms: linux/arm64,linux/amd64
39100
push: true
40-
tags: ghcr.io/${{ matrix.endpoint }},ghcr.io/${{ matrix.endpoint }}:${{ github.sha }}
101+
tags: ghcr.io/demeter-run/ext-cardano-dbsync-serverless,ghcr.io/ext-cardano-dbsync-serverless:${{ github.sha }}

0 commit comments

Comments
 (0)