From a3bef45e613b3ba06cd87243bfe344a099e02f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20B=C3=A4lter?= Date: Wed, 11 Mar 2026 10:31:11 +0100 Subject: [PATCH 1/5] Build Ruby images for multiple versions with runtime/build split Matrix builds latest patches of each supported minor (3.4.8, 3.3.7). Each version produces two images: - ruby: (runtime: slim + curl + postgresql-client) - ruby:-build (runtime + build-essential, git, libpq-dev, etc.) Also tags minor aliases (ruby:3.4, ruby:3.4-build) and latest. --- .github/workflows/ruby.yml | 44 ++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 7658db2..3e350bd 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -20,6 +20,12 @@ jobs: permissions: contents: read packages: write + strategy: + matrix: + ruby-version: ["3.4.8", "3.3.7"] + include: + - ruby-version: "3.4.8" + latest: true steps: - uses: actions/checkout@v6 @@ -30,17 +36,37 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - uses: docker/metadata-action@v6 - id: meta + - name: Generate tags + id: tags + run: | + IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" + VERSION="${{ matrix.ruby-version }}" + MINOR="${VERSION%.*}" + + RUNTIME="${IMAGE}:${VERSION},${IMAGE}:${MINOR}" + BUILD="${IMAGE}:${VERSION}-build,${IMAGE}:${MINOR}-build" + if [ "${{ matrix.latest }}" = "true" ]; then + RUNTIME="${RUNTIME},${IMAGE}:latest" + BUILD="${BUILD},${IMAGE}:latest-build" + fi + + echo "runtime=${RUNTIME}" >> "$GITHUB_OUTPUT" + echo "build=${BUILD}" >> "$GITHUB_OUTPUT" + + - name: Build and push runtime image + uses: docker/build-push-action@v7 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=raw,value=latest,enable={{is_default_branch}} - type=sha + context: ruby + target: base + build-args: RUBY_VERSION=${{ matrix.ruby-version }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.tags.outputs.runtime }} - - uses: docker/build-push-action@v7 + - name: Build and push build image + uses: docker/build-push-action@v7 with: context: ruby + target: build + build-args: RUBY_VERSION=${{ matrix.ruby-version }} push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: ${{ steps.tags.outputs.build }} From 140bcaf477ba1381a0e3238051c0b9f0868fd3c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20B=C3=A4lter?= Date: Wed, 11 Mar 2026 10:34:53 +0100 Subject: [PATCH 2/5] Simplify to single image per version, drop runtime/build split One image with build tools included. Simpler to maintain, and the size difference doesn't matter for Heroku apps. Tags: ruby:3.4.8, ruby:3.4, ruby:latest (+ 3.3.7, 3.3) --- .github/workflows/ruby.yml | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 3e350bd..b393856 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -43,30 +43,16 @@ jobs: VERSION="${{ matrix.ruby-version }}" MINOR="${VERSION%.*}" - RUNTIME="${IMAGE}:${VERSION},${IMAGE}:${MINOR}" - BUILD="${IMAGE}:${VERSION}-build,${IMAGE}:${MINOR}-build" + TAGS="${IMAGE}:${VERSION},${IMAGE}:${MINOR}" if [ "${{ matrix.latest }}" = "true" ]; then - RUNTIME="${RUNTIME},${IMAGE}:latest" - BUILD="${BUILD},${IMAGE}:latest-build" + TAGS="${TAGS},${IMAGE}:latest" fi - echo "runtime=${RUNTIME}" >> "$GITHUB_OUTPUT" - echo "build=${BUILD}" >> "$GITHUB_OUTPUT" + echo "tags=${TAGS}" >> "$GITHUB_OUTPUT" - - name: Build and push runtime image - uses: docker/build-push-action@v7 + - uses: docker/build-push-action@v7 with: context: ruby - target: base build-args: RUBY_VERSION=${{ matrix.ruby-version }} push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.tags.outputs.runtime }} - - - name: Build and push build image - uses: docker/build-push-action@v7 - with: - context: ruby - target: build - build-args: RUBY_VERSION=${{ matrix.ruby-version }} - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.tags.outputs.build }} + tags: ${{ steps.tags.outputs.tags }} From a232aba85e2d06d0424f46df3024c3b70cacd413 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Wed, 11 Mar 2026 10:48:27 +0100 Subject: [PATCH 3/5] Tweak the matrix - No need to repeat 3.4.8 - Make the list diff friendly - Add 4.0.1 - Build latest 3.3 --- .github/workflows/ruby.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index b393856..0ea1936 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -22,7 +22,9 @@ jobs: packages: write strategy: matrix: - ruby-version: ["3.4.8", "3.3.7"] + ruby-version: + - "3.3.10" + - "4.0.1" include: - ruby-version: "3.4.8" latest: true From fdfa12a2a0ab81701bf4c69b9346c432d237a5de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20B=C3=A4lter?= Date: Wed, 11 Mar 2026 10:50:56 +0100 Subject: [PATCH 4/5] Drop latest and minor aliases, tag only exact versions Explicit versions only: ruby:3.3.10, ruby:3.4.8, ruby:4.0.1. No latest, no minor aliases. Apps pin the exact version they need. --- .github/workflows/ruby.yml | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 0ea1936..44256ae 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -22,12 +22,7 @@ jobs: packages: write strategy: matrix: - ruby-version: - - "3.3.10" - - "4.0.1" - include: - - ruby-version: "3.4.8" - latest: true + ruby-version: ["3.3.10", "3.4.8", "4.0.1"] steps: - uses: actions/checkout@v6 @@ -38,23 +33,9 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Generate tags - id: tags - run: | - IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" - VERSION="${{ matrix.ruby-version }}" - MINOR="${VERSION%.*}" - - TAGS="${IMAGE}:${VERSION},${IMAGE}:${MINOR}" - if [ "${{ matrix.latest }}" = "true" ]; then - TAGS="${TAGS},${IMAGE}:latest" - fi - - echo "tags=${TAGS}" >> "$GITHUB_OUTPUT" - - uses: docker/build-push-action@v7 with: context: ruby build-args: RUBY_VERSION=${{ matrix.ruby-version }} push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.tags.outputs.tags }} + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.ruby-version }} From f54ff85b58f18c6e0f61276a57ccae4010e5b606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20B=C3=A4lter?= Date: Wed, 11 Mar 2026 10:52:53 +0100 Subject: [PATCH 5/5] List ruby versions one per line --- .github/workflows/ruby.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 44256ae..8615333 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -22,7 +22,10 @@ jobs: packages: write strategy: matrix: - ruby-version: ["3.3.10", "3.4.8", "4.0.1"] + ruby-version: + - "3.3.10" + - "3.4.8" + - "4.0.1" steps: - uses: actions/checkout@v6