Skip to content

Commit 81fd1ad

Browse files
authored
Fix builds by switching to native arm64 runners (#21)
* Update default build to 3.4.1, update rust dependency * Extend matrix to use platform-specific runners * Merge builds into multiarch image
1 parent 364ab96 commit 81fd1ad

3 files changed

Lines changed: 65 additions & 16 deletions

File tree

.github/workflows/build-push.yaml

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Build-Test-Push
2+
23
on:
34
schedule:
45
- cron: "5 4 * * 3"
@@ -13,32 +14,34 @@ on:
1314

1415
jobs:
1516
gather-versions:
16-
runs-on: ubuntu-22.04
17+
runs-on: ubuntu-24.04
1718
outputs:
1819
versions: ${{ steps.ruby-versions.outputs.versions }}
1920
metadata: ${{ steps.ruby-versions.outputs.metadata }}
2021
steps:
2122
- uses: moritzheiber/ruby-versions-action@v1
2223
name: Fetch latest Ruby versions
2324
id: ruby-versions
25+
2426
build-test-push:
25-
runs-on: ubuntu-22.04
2627
needs: ["gather-versions"]
2728
strategy:
2829
matrix:
2930
version: ${{ fromJSON(needs.gather-versions.outputs.versions) }}
30-
image: ["slim", "ubuntu-22.04", "ubuntu-24.04"]
31+
image: [slim, ubuntu-22.04, ubuntu-24.04]
32+
platform: [amd64, arm64]
3133
include: ${{ fromJSON(needs.gather-versions.outputs.metadata) }}
34+
runs-on: ${{ matrix.platform == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
3235
steps:
3336
- name: Set image_name
3437
id: context
3538
run: |
3639
if [[ "${{ matrix.image }}" == "slim" ]] ; then
3740
echo "image_name=ruby:${{ matrix.version }}-slim" >> ${GITHUB_OUTPUT}
3841
elif [[ "${{ matrix.image }}" == "ubuntu-22.04" ]] ; then
39-
echo "image_name=ubuntu:20.04" >> ${GITHUB_OUTPUT}
40-
elif [[ "${{ matrix.image }}" == "ubuntu-24.04" ]] ; then
4142
echo "image_name=ubuntu:22.04" >> ${GITHUB_OUTPUT}
43+
elif [[ "${{ matrix.image }}" == "ubuntu-24.04" ]] ; then
44+
echo "image_name=ubuntu:24.04" >> ${GITHUB_OUTPUT}
4245
fi
4346
4447
if [[ "${{ startsWith(matrix.version, '3.2') }}" == "true" ]] ; then
@@ -51,21 +54,67 @@ jobs:
5154
registry: ghcr.io
5255
username: ${{ github.actor }}
5356
password: ${{ secrets.GITHUB_TOKEN }}
54-
- uses: docker/setup-qemu-action@v3
5557
- uses: docker/setup-buildx-action@v3
5658
with:
5759
driver-opts: |
58-
image=moby/buildkit:v0.10.6
60+
image=moby/buildkit:v0.19.0
5961
- uses: docker/build-push-action@v6
6062
name: Build
63+
id: build
6164
with:
62-
platforms: linux/amd64,linux/arm64
65+
platforms: linux/${{ matrix.platform }}
6366
push: ${{ github.ref == 'refs/heads/main' }}
6467
cache-from: type=gha
65-
cache-to: type=gha
68+
cache-to: type=gha,mode=max
6669
build-args: |
6770
RUBY_VERSION=${{ matrix.version }}
6871
RUBY_CHECKSUM=${{ matrix.checksum }}
6972
IMAGE_NAME=${{ steps.context.outputs.image_name }}
7073
ADDITIONAL_FLAGS=${{ steps.context.outputs.flags }}
71-
tags: "ghcr.io/moritzheiber/ruby-jemalloc:${{ matrix.version }}-${{ matrix.image }}"
74+
provenance: false
75+
outputs: |
76+
type=image,name=ghcr.io/${{ github.repository }},push-by-digest=true,push=${{ github.ref == 'refs/heads/main' }}
77+
- name: Export digest
78+
if: github.ref == 'refs/heads/main'
79+
run: |
80+
mkdir -p /tmp/digests/${{ matrix.version }}-${{ matrix.image }}
81+
digest="${{ steps.build.outputs.digest }}"
82+
touch "/tmp/digests/${{ matrix.version }}-${{ matrix.image }}/${digest#sha256:}"
83+
- name: Upload digest
84+
if: github.ref == 'refs/heads/main'
85+
uses: actions/upload-artifact@v3
86+
with:
87+
name: digests-${{ matrix.version }}-${{ matrix.image }}
88+
path: /tmp/digests/${{ matrix.version }}-${{ matrix.image }}/*
89+
if-no-files-found: error
90+
retention-days: 1
91+
92+
merge-manifests:
93+
needs: ["build-test-push", "gather-versions"]
94+
if: github.ref == 'refs/heads/main'
95+
runs-on: ubuntu-24.04
96+
strategy:
97+
matrix:
98+
version: ${{ fromJSON(needs.gather-versions.outputs.versions) }}
99+
image: [slim, ubuntu-22.04, ubuntu-24.04]
100+
steps:
101+
- name: Login to GHCR
102+
uses: docker/login-action@v3
103+
with:
104+
registry: ghcr.io
105+
username: ${{ github.actor }}
106+
password: ${{ secrets.GITHUB_TOKEN }}
107+
- uses: docker/setup-buildx-action@v3
108+
with:
109+
driver-opts: |
110+
image=moby/buildkit:v0.19.0
111+
- name: Download digests
112+
uses: actions/download-artifact@v3
113+
with:
114+
name: digests-${{ matrix.version }}-${{ matrix.image }}
115+
path: /tmp/digests/${{ matrix.version }}-${{ matrix.image }}
116+
- name: Create and push manifest
117+
working-directory: /tmp/digests/${{ matrix.version }}-${{ matrix.image }}
118+
run: |
119+
docker buildx imagetools create -t ghcr.io/${{ github.repository }}:${{ matrix.version }}-${{ matrix.image }} \
120+
$(printf 'ghcr.io/${{ github.repository }}@sha256:%s ' *)

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG RUBY_VERSION="3.3.1"
1+
ARG RUBY_VERSION="3.4.1"
22
ARG IMAGE_NAME="ruby:${RUBY_VERSION}-slim"
33
# hadolint ignore=DL3006
44
FROM ${IMAGE_NAME}
@@ -7,7 +7,7 @@ LABEL maintainer="Moritz Heiber <hello@heiber.im>"
77
LABEL org.opencontainers.image.source=https://github.com/moritzheiber/ruby-jemalloc-docker
88

99
ARG RUBY_VERSION
10-
ARG RUBY_CHECKSUM="8dc2af2802cc700cd182d5430726388ccf885b3f0a14fcd6a0f21ff249c9aa99"
10+
ARG RUBY_CHECKSUM="3d385e5d22d368b064c817a13ed8e3cc3f71a7705d7ed1bae78013c33aa7c87f"
1111
ARG ADDITIONAL_FLAGS
1212

1313
ENV DEBIAN_FRONTEND="noninteractive" \
@@ -31,7 +31,7 @@ RUN apt-get update && \
3131
libffi-dev \
3232
zlib1g-dev \
3333
libssl-dev && \
34-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain=1.77.0 && \
34+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain=1.84.0 && \
3535
source "${HOME}/.cargo/env" && \
3636
curl -L -o "ruby-${RUBY_VERSION}.tar.gz" "https://cache.ruby-lang.org/pub/ruby/${RUBY_VERSION%.*}/ruby-${RUBY_VERSION}.tar.gz" && \
3737
echo "${RUBY_CHECKSUM} ruby-${RUBY_VERSION}.tar.gz" | sha256sum --strict -c - && \

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ $ docker build \
9292
--build-arg IMAGE_NAME=ubuntu:22.04 \
9393
-t ruby-jemalloc:3.1.4-ubuntu-22.04 .
9494
```
95-
_Note: Ruby `3.3.1-slim` is the default when building the Docker image without any build arguments._
95+
_Note: Ruby `3.4.1-slim` is the default when building the Docker image without any build arguments._
9696

9797
## Tests
9898

@@ -105,7 +105,7 @@ dgoss run -ti ruby-jemalloc
105105
You can specify the Ruby version to test for by passing `RUBY_VERSION` as a variable:
106106

107107
```console
108-
dgoss run -ti -e RUBY_VERSION=3.3.1 ruby-jemalloc
108+
dgoss run -ti -e RUBY_VERSION=3.4.1 ruby-jemalloc
109109
```
110110

111-
_Note: `3.3.1` is the default. And don't forget to also pass the correct `RUBY_CHECKSUM`._
111+
_Note: `3.4.1` is the default. And don't forget to also pass the correct `RUBY_CHECKSUM`._

0 commit comments

Comments
 (0)