From ae4c04b3ad7be219ace48f32632e8ef09bb7d7d6 Mon Sep 17 00:00:00 2001 From: Russell Porter Date: Mon, 23 Nov 2026 23:29:43 +0100 Subject: [PATCH 1/3] Fix the production image crashing on boot The image published since 2026-11-16 fails at startup with "unknown keyword: create_additions": json 3 (taken in #199) removed that keyword, and sprockets 4.2.1 still passes it when it loads the asset manifest. That manifest only exists in the production image, so CI's tests passed. - Update sprockets to 4.4.1, which no longer passes it. - Update puma to 8.1.2, which fixes the advisories bundle-audit reports for 8.1.1 (the audit job, and so the image push, fails on master). - Build the image on Ruby 3.3.14, the version in .ruby-version that CI tests with, instead of the Ruby 4.0 that #206 put in the Dockerfile only. Dependabot no longer updates the Dockerfile's Ruby; the Ruby version bump workflow updates both files. - CI: a new image job builds the production image and boots the app in it, and the push job does the same before publishing. - CI: rebuild and publish master weekly (Tuesday 09:00 UTC). Dependabot merges are made with GITHUB_TOKEN, which doesn't trigger the push build, so those updates were never published. - Don't auto-merge Dependabot major updates; they wait for review. --- .github/dependabot.yml | 5 ++ .github/workflows/ci.yml | 79 ++++++++++++++++++++- .github/workflows/dependabot-auto-merge.yml | 13 ++++ .ruby-version | 2 +- Dockerfile | 2 +- Gemfile | 3 +- Gemfile.lock | 7 +- 7 files changed, 102 insertions(+), 9 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 4797bc4..b86a35e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -48,3 +48,8 @@ updates: timezone: "UTC" cooldown: default-days: 7 + ignore: + # Dependabot only changes the Dockerfile, but CI tests on .ruby-version, so a + # Ruby bump from here ships a Ruby that CI never ran. The Ruby version bump + # workflow updates both; a new Ruby series is a deliberate upgrade. + - dependency-name: "ruby" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6acad39..12946db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,11 @@ on: - master pull_request: workflow_dispatch: + # Weekly rebuild of the published image, before WhyJustRun's Tuesday 10:30 UTC + # redeploy. It picks up base-image fixes, and the Dependabot updates merged that + # week: merges made with GITHUB_TOKEN don't trigger the push event. + schedule: + - cron: "0 9 * * 2" permissions: contents: read @@ -155,10 +160,28 @@ jobs: - name: Audit gems for known vulnerabilities run: gem install bundler-audit --no-document && bundle-audit check --update - push: + image: runs-on: ubuntu-24.04 - needs: [test, system-test, brakeman, audit] - if: github.event_name == 'push' + env: + RAILS_ENV: production + SECRET_KEY_BASE: placeholder + WJR_DATABASE_NAME: placeholder + WJR_DATABASE_TEST_NAME: placeholder + WJR_DATABASE_HOST: placeholder + WJR_DATABASE_USERNAME: placeholder + WJR_DATABASE_PASSWORD: placeholder + WJR_PASSWORD_SALT: placeholder + WJR_SECRET_BASE: placeholder + WJR_SECRET_TOKEN: placeholder + WJR_DEVISE_SECRET_KEY: placeholder + WJR_RECAPTCHA_SITE_KEY: placeholder + WJR_RECAPTCHA_SECRET_KEY: placeholder + WJR_SMTP_ADDRESS: placeholder + WJR_SMTP_DOMAIN: placeholder + WJR_SMTP_USER_NAME: placeholder + WJR_SMTP_PASSWORD: placeholder + WJR_DATA_FOLDER: /tmp/whyjustrun-data/ + WJR_DATA_URL: placeholder steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 @@ -166,6 +189,56 @@ jobs: - name: Build image run: docker build . --file Dockerfile --tag $IMAGE_NAME + - name: Check that the app boots in production + # The test jobs run on the runner's Ruby without precompiled assets; this runs + # the image that gets deployed (its Ruby, its gems, its asset manifest). + run: | + env_args=() + for name in RAILS_ENV SECRET_KEY_BASE ${!WJR_*}; do env_args+=(-e "$name"); done + docker run --rm --entrypoint "" "${env_args[@]}" $IMAGE_NAME \ + bundle exec rails runner 'puts "Booted Rails #{Rails.version} on Ruby #{RUBY_VERSION}"' + + push: + runs-on: ubuntu-24.04 + needs: [test, system-test, brakeman, audit, image] + # Only master is published (as `latest`), never a branch the CI was dispatched on. + if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' + env: + RAILS_ENV: production + SECRET_KEY_BASE: placeholder + WJR_DATABASE_NAME: placeholder + WJR_DATABASE_TEST_NAME: placeholder + WJR_DATABASE_HOST: placeholder + WJR_DATABASE_USERNAME: placeholder + WJR_DATABASE_PASSWORD: placeholder + WJR_PASSWORD_SALT: placeholder + WJR_SECRET_BASE: placeholder + WJR_SECRET_TOKEN: placeholder + WJR_DEVISE_SECRET_KEY: placeholder + WJR_RECAPTCHA_SITE_KEY: placeholder + WJR_RECAPTCHA_SECRET_KEY: placeholder + WJR_SMTP_ADDRESS: placeholder + WJR_SMTP_DOMAIN: placeholder + WJR_SMTP_USER_NAME: placeholder + WJR_SMTP_PASSWORD: placeholder + WJR_DATA_FOLDER: /tmp/whyjustrun-data/ + WJR_DATA_URL: placeholder + + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + + - name: Build image + run: docker build . --pull --file Dockerfile --tag $IMAGE_NAME + + - name: Check that the app boots in production + # The test jobs run on the runner's Ruby without precompiled assets; this runs + # the image that gets deployed (its Ruby, its gems, its asset manifest). + run: | + env_args=() + for name in RAILS_ENV SECRET_KEY_BASE ${!WJR_*}; do env_args+=(-e "$name"); done + docker run --rm --entrypoint "" "${env_args[@]}" $IMAGE_NAME \ + bundle exec rails runner 'puts "Booted Rails #{Rails.version} on Ruby #{RUBY_VERSION}"' + - name: Log into GitHub Container Registry run: echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ secrets.CR_USER }} --password-stdin diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index 7a88b53..0f67de7 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -18,7 +18,14 @@ jobs: github.event.pull_request.user.login == 'dependabot[bot]' runs-on: ubuntu-latest steps: + - name: Fetch update metadata + id: metadata + uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0 + + # Major updates can break the app in ways the tests miss (json 3 did), so they + # wait for a human review. - name: Enable auto-merge + if: steps.metadata.outputs.update-type != 'version-update:semver-major' run: gh pr merge --auto --squash "$PR_URL" env: PR_URL: ${{ github.event.pull_request.html_url }} @@ -50,6 +57,12 @@ jobs: exit 0 fi + # Major updates wait for a human review (see enable-auto-merge). + if gh api "repos/$REPO/commits/$HEAD_SHA" --jq '.commit.message' | grep -q 'update-type: version-update:semver-major'; then + echo "PR #$pr is a major update; leaving it for review" + exit 0 + fi + state=$(gh pr view "$pr" --repo "$REPO" --json state --jq '.state') if [ "$state" != "OPEN" ]; then echo "PR #$pr is $state; skipping" diff --git a/.ruby-version b/.ruby-version index a0891f5..4efd0fb 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.3.4 +3.3.14 diff --git a/Dockerfile b/Dockerfile index 8d0687b..7b7ae94 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:4.0.0-alpine AS dev +FROM ruby:3.3.14-alpine AS dev RUN apk add --no-cache \ make \ pkgconfig \ diff --git a/Gemfile b/Gemfile index 31cdb11..cdd1864 100644 --- a/Gemfile +++ b/Gemfile @@ -46,7 +46,8 @@ gem "geocoder", "~> 1.8.6" # JSON Builder gem 'jbuilder', '~> 2.15.1' -# json 3 removed keywords still used by Rails 7.x and ExecJS 2.9. +# json 3 removed the create_additions keyword, which sprockets 4.2 still passed (4.4 doesn't). +# Before taking json 4, check that the production image boots (CI's image job). gem 'json', '< 4' # Logging (email) diff --git a/Gemfile.lock b/Gemfile.lock index c04927c..50d7b4e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -210,7 +210,7 @@ GEM prism (2.1.0) prism (2.1.0-x86_64-linux-gnu) public_suffix (7.0.5) - puma (8.1.1) + puma (8.1.2) nio4r (~> 2.0) pundit (2.5.2) activesupport (>= 3.0.0) @@ -287,8 +287,9 @@ GEM logger (~> 1.4) rubyzip (>= 1.2.2, < 4.0) websocket (~> 1.0) - sprockets (4.2.1) - concurrent-ruby (~> 1.0) + sprockets (4.4.1) + concurrent-ruby (~> 1.1) + logger rack (>= 2.2.4, < 4) sprockets-rails (3.5.2) actionpack (>= 6.1) From 6f29283655abe87a30b29db600e3c550e73c6877 Mon Sep 17 00:00:00 2001 From: Russell Porter Date: Mon, 23 Nov 2026 23:30:51 +0100 Subject: [PATCH 2/3] Use Ruby 3.3.13: the pinned setup-ruby doesn't know 3.3.14 yet setup-ruby added 3.3.14 in v1.343.0 (2026-11-20), still inside the 7-day Dependabot cooldown. Once Dependabot updates it, the Ruby version bump workflow opens the 3.3.14 update. --- .ruby-version | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.ruby-version b/.ruby-version index 4efd0fb..6c165c2 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.3.14 +3.3.13 diff --git a/Dockerfile b/Dockerfile index 7b7ae94..32e3b7d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:3.3.14-alpine AS dev +FROM ruby:3.3.13-alpine AS dev RUN apk add --no-cache \ make \ pkgconfig \ From cb22b1cfcda7dd6a24bbb6eba08924348d74acd8 Mon Sep 17 00:00:00 2001 From: Russell Porter Date: Mon, 23 Nov 2026 23:34:41 +0100 Subject: [PATCH 3/3] Install linux-headers and libffi-dev for the ffi gem Building on the current Alpine fails compiling ffi's bundled libffi (linux/limits.h: No such file or directory). The Alpine 3.20 base of the last working image had both packages as dependencies of the others. --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index 32e3b7d..cb85317 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,13 @@ FROM ruby:3.3.13-alpine AS dev +# linux-headers and libffi-dev are for compiling the ffi gem; older Alpine releases +# pulled them in as dependencies of the other packages. RUN apk add --no-cache \ make \ pkgconfig \ build-base \ autoconf \ + linux-headers \ + libffi-dev \ libstdc++ \ mariadb-dev \ imagemagick \