Skip to content

Add the Laravel for Rust dev image (ALI-2447) - #1

Merged
michaelaguiar merged 5 commits into
mainfrom
ali-2447-laravel-rust-dev-image
Dec 2, 2026
Merged

michaelaguiar merged 5 commits into
mainfrom
ali-2447-laravel-rust-dev-image

Conversation

@michaelaguiar

Copy link
Copy Markdown
Member

Part of ALI-2446. This moves the Laravel for Rust dev image out of docker-php (aliasproject/docker-php#23, closed in favour of this PR) into its own repo, and adds CI that builds and boots it. Ingot runs it for Laravel for Rust projects (aliasproject/ingot#19, merged).

What's in it

  • laravel-rust/Dockerfile.dev and docker-entrypoint: unchanged from docker-php#23's final head (ca4859b), which had three review rounds and was tested by hand on arm64 (M1) and amd64:
    • Rust 1.99 with rustfmt and clippy, and Node 24.
    • The Laravel CLI 0.3.0, checked against its sha256.sum.
    • An entrypoint that installs node_modules before laravel dev.
    • tini as PID 1.
    • Cargo cache folders writable by group 0.
  • .github/workflows/build.yml: builds the image on a native amd64 runner and a native ubuntu-24.04-arm runner. It runs on pull requests, pushes to main, a Monday rebuild (no layer cache) and manual runs.
  • .github/scripts/smoke-test.sh: the hand tests from docker-php#23, made repeatable. On each architecture it:
    1. checks the toolchain and that the image doesn't run as root;
    2. makes a new app with laravel new --rust, as the runner's UID 1001 in group 0, with the Cargo cache volumes mounted;
    3. runs laravel migrate on its own and checks that it doesn't install node_modules;
    4. runs laravel dev against Postgres 17 and waits for /up to answer 200;
    5. checks that the entrypoint installed node_modules, and that target/ and node_modules/ belong to the runner's user;
    6. edits src/ and waits for the server to restart and answer again;
    7. checks that docker stop takes under 5 seconds.
  • README: the image's documentation from docker-php#23, plus the checks and how publishing works.
  • .github/workflows/secret-scan.yml (on main): the same gitleaks scan as docker-php.

Publishing is off

Merging publishes nothing. Publishing turns on when the repository variable PUBLISH_IMAGES is set to true. From then on, pushes to main, the weekly rebuild and manual runs work like this:

  1. Each architecture's image is pushed to ghcr.io/aliasproject/laravel-rust by digest, without a tag.
  2. The smoke test runs against that exact digest.
  3. A final job tags both digests as one multi-arch image, dev and dev-<commit>, but only if both architectures passed.

Pull requests never publish. After the first publish, make the laravel-rust package public in its GHCR settings, because Ingot pulls without logging in.

dev is the tag Ingot runs today (project.LaravelRustImage). A scheme by Rust version, such as 1.99-dev, would need that constant changed too.

Testing

  • actionlint and shellcheck pass.
  • This PR's own CI run is the first run of the workflow and the smoke test on both architectures; see the checks below.
  • The image itself is the one tested by hand in docker-php#23.

…(ALI-2447)

Moved from aliasproject/docker-php#23, where it was reviewed and tested
on amd64 and arm64: a dev image for Laravel for Rust apps as Ingot runs
them (Rust 1.99, Node 24, the Laravel CLI 0.3.0 checked against its
sha256, an entrypoint that installs node_modules before laravel dev,
tini as PID 1, Cargo cache folders writable by group 0).

build.yml builds it on native amd64 and arm64 runners and runs
smoke-test.sh, which makes a new app with laravel new --rust and checks
laravel dev serves /up, restarts on an edit, writes files as the calling
user and stops promptly. Publishing to ghcr.io/aliasproject/laravel-rust
stays off until the PUBLISH_IMAGES repository variable is true.
The amd64 run failed 'the entrypoint didn't install node_modules' although
/up had answered (laravel dev can't start without node_modules). grep -q
exits at its first match; docker logs, still writing, then fails, and
pipefail fails the whole check. arm64 passed only by timing. The log
checks now read the logs into a string first, and the container check
compares docker ps output instead of piping it.
Review findings on the new workflow and smoke test:
- With PUBLISH_IMAGES on, a manual run on any branch would have tagged
  that branch's image as dev, the tag Ingot pulls. Publishing now also
  requires refs/heads/main.
- The publish job can't be cancelled part-way by a newer run (its own
  concurrency group), so dev and dev-<sha> aren't split.
- Jobs time out (45 and 10 minutes) instead of GitHub's 6 hours.
- The restart check also waits for cargo's Finished after nodemon's
  restart line, since the old server answers /up until it's killed.
- laravel migrate waits for Postgres to accept connections first.
- The final rm in cleanup can't fail a passing run.
- The README says Markdown-only changes don't trigger a build.
@michaelaguiar

Copy link
Copy Markdown
Member Author

Review round 1 (fresh reviewer). The code-review skill reviewed the wrong checkout (docker-php#23's worktree), so I discarded its output. The reviewer then reviewed this diff by hand.

CI: the first amd64 run failed "the entrypoint didn't install node_modules" even though /up had answered. Under pipefail, docker logs | grep -q fails whenever grep exits at its first match before docker logs finishes writing, and arm64 passed only by timing. Fixed in 05d42b1: logs are read into a string before they're searched. Both architectures then passed, with /up in 10s, a restart in 3–7s and a stop in 1–2s.

Findings:

  1. P2, fixed in 9da2d54: with PUBLISH_IMAGES on, a manual run on any branch would have tagged that branch's image as dev. Publishing now also requires refs/heads/main, and the README and the workflow comment say so.
  2. P3, fixed: the restart check could pass on the old server, which answers /up until nodemon kills it. It now also waits for cargo's Finished after the restart line.
  3. P3, fixed: jobs had no timeout-minutes, so a hung laravel new would have held a runner for 6 hours. They now time out after 45 minutes (build) and 10 (publish).
  4. P3, fixed: cleanup's final rm -rf could turn a passing run into a failure. It now can't.
  5. P3, fixed: laravel migrate ran without waiting for Postgres. It now polls pg_isready first.
  6. P3, fixed: a newer run could cancel the publish job between the two tags. The publish job now has its own concurrency group with cancel-in-progress: false.
  7. P3, fixed: the README said "every pull request", but Markdown-only changes are skipped. The README now says so.
  8. P3, declined: --since has one-second resolution, so a restart line from earlier in the same second could match. Nothing restarts the server before the edit, so it can't happen in practice.

Confirmed to hold:

  • The publish path's expressions, digest outputs and artifact names.
  • The smoke test pulls by digest after the login step.
  • With publishing off, the weekly run never logs in or pushes.
  • The cleanup trap covers failures.

Round 2 review: the workflow-level concurrency group still cancelled an
older run on main, publish job included, so the job-level group didn't
keep dev and dev-<sha> together. Runs on main now queue; other refs
still cancel. And pg_isready over the Unix socket can answer during the
image's first-start temporary server, before Postgres listens on TCP,
which the app uses; it now checks 127.0.0.1.
@michaelaguiar

Copy link
Copy Markdown
Member Author

Review rounds 2 and 3

  • Round 2, P2, fixed in d212cab: the job-level concurrency group didn't stop the workflow-level group from cancelling an older run on main, publish job included. Runs on main no longer cancel each other, and other refs still do.
  • Round 2, P3, fixed in d212cab: pg_isready over the Unix socket could answer during the Postgres image's socket-only first-start server. It now checks TCP on 127.0.0.1, as the app connects.
  • Round 3, P3, fixed in the comment-only commit after d212cab: GitHub keeps one pending run per group, and a newer pending run replaces it. A skipped commit therefore gets no dev-<sha> tag, but a running publish is never cut short. The workflow comment now says so.

Round 3 also confirmed that cancel-in-progress evaluates as intended for push, schedule, manual and pull request runs, and that the TCP check works in postgres:17-alpine. The reviews stop here.

@michaelaguiar
michaelaguiar marked this pull request as ready for review December 2, 2026 01:00
@michaelaguiar
michaelaguiar merged commit 7763813 into main Dec 2, 2026
5 checks passed
@michaelaguiar
michaelaguiar deleted the ali-2447-laravel-rust-dev-image branch December 2, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant