Repository navigation
Add a Laravel for Rust dev image (ALI-2447) - #23
michaelaguiar wants to merge 5 commits into
Conversation
Rust 1.99, Node 24 and the Laravel CLI 0.3.0 (pinned, checked against the release's sha256.sum), running laravel dev against /app as the host user in group 0. Cargo's registry, git and build folders exist and are group-0 writable, so the shared volumes Ingot mounts there are writable.
…E (ALI-2447) laravel dev runs the app's npm run dev and doesn't install node_modules, so a cloned project started with only Vite's 'not found'. The entrypoint installs them when they're missing. TARGETARCH is only set by BuildKit; fall back to dpkg's architecture so the legacy builder works too.
…e_modules (ALI-2447) The recursive chgrp/chmod over CARGO_HOME and RUSTUP_HOME changed nothing (the official image already makes them world-writable), so it now sets only the three cache folders Ingot mounts volumes on. The README now says node_modules installed in the container are built for Linux, which breaks a host-side npm run dev on macOS and Windows.
Review round 1A fresh-context review of 186a999. The code-review skill ran against the wrong repository (it looked for the branch in the Ingot checkout), so the reviewer discarded its output and reviewed the diff by hand. The review was static only, with no Docker builds, because a benchmark was running on that machine. No P1 or P2 findings. The reviewer confirmed:
Fixed in ef04d13
Declined
|
…for laravel dev (ALI-2447) rustfmt and clippy were added as root after the base image made RUSTUP_HOME world-writable, so a non-root update or removal of them failed; restore the base's a+w. Without an init, laravel dev was PID 1 and docker stop (and Ingot's idle stop) waited out the timeout before killing it mid-build; tini forwards the signal (stop now takes ~0.1s). The entrypoint installed node_modules before any command, so a one-off laravel migrate in a fresh clone ran a full npm ci first, and it trusted a partial node_modules from an interrupted install. It now installs only before laravel dev, when npm's node_modules/.package-lock.json is missing.
Review round 2A fresh-context review of ef04d13. code-review ran against the PR this time. The review was static; the M1 results below are mine. Fixed in 9f305fc (rebuilt on the M1 and the whole loop re-run with a fresh
Declined
|
…roup (ALI-2447) A recursive chmod over the toolchain could copy all of it into the layer under BuildKit (the legacy builder measured 28.5 MB either way); find now touches only files that aren't already world-writable. tini -g sends docker stop's signal to the whole process group, so nodemon and cargo get it too, not only the laravel CLI. The README says which commands install node_modules.
Review round 3A narrow fresh-context review of 9f305fc. code-review ran. No P1. The reviewer confirmed the entrypoint's quoting and Fixed in ca4859b (rebuilt and checked on the M1)
Declined
Stopping the review here: three rounds, and this round's fixes are small and verified. Left: the amd64 build, which waits for the desktop to be free. |
|
Closing: the image moved, unchanged, to its own repo in aliasproject/docker-rust#1, which adds CI that builds it on native amd64 and arm64 runners and boots a new |
* Add the Laravel for Rust dev image, with CI that builds and boots it (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. * Smoke test: don't pipe docker logs into grep -q under pipefail 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. * Publish only from main; harden the smoke test (ALI-2447) 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. * Don't cancel runs on main; wait for Postgres over TCP (ALI-2447) 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. * Describe how runs on main wait for each other (ALI-2447)
Part of ALI-2446. This adds
laravel-rust/Dockerfile.dev, a development image for Laravel for Rust apps, the way Ingot runs them (aliasproject/ingot#19). The project is mounted at/app, and the container runslaravel devas the host user in group 0.What's in it
rustfmtandclippy, plus Node 24 copied from the official Node image.laravel/cli-releases, checked against the release'ssha256.sum, instead of pipinglaravel.com/install.shto a shell. The CLI has no Alpine (musl) build for arm64, so the image is Debian.laravel devruns the app'snpm run dev(server, queue worker and Vite) but doesn't installnode_modules. Beforelaravel dev, the entrypoint installs them when npm'snode_modules/.package-lock.jsonis missing. Other commands start as they are.-g, sodocker stop(and Ingot's idle stop) reacheslaravel dev,nodemonandcargoat once.CARGO_HOME'sregistry,gitandbuildfolders exist and are writable by group 0. Ingot mounts shared volumes there, and a new volume takes the ownership of the folder it's mounted on.HOME=/home/appis writable by any UID in group 0, andSERVER_HOST=0.0.0.0/SERVER_PORT=80are set.TARGETARCHfalls back todpkg --print-architecture, because the legacy builder doesn't set it.Not in this PR: publishing
CI doesn't build or publish this image:
build-and-push.ymlis unchanged, so merging publishes nothing. Publishing needs decisions first:ghcr.io/aliasproject/laravel-rust:dev, inproject.LaravelRustImage);1.99-dev);That can be a follow-up PR once those are settled.
Testing
On the M1 (arm64, Docker 29, legacy builder):
laravel --versionprints 0.3.0.laravel new example-app --rustinside the image downloaded, installed and compiled the starter app in about 33s, using cache volumes mounted like Ingot's.laravel dev, run as Ingot will run it (--user <uid>:0, bind mount, the three cache volumes,SERVER_HOST,SERVER_PORT,APP_URL), withnode_modulesdeleted first:/upreturned 200 about 10s after start;laravel migrate, run throughdocker exec, worked;src/madenodemonrebuild and restart the server in 4.8s.target/andnode_modules/belong to the host user, and the cache folders are 775, group 0.server/: compiled in 26s, ran its 16 migrations and served/up(200) and/(302 to sign-in).On the desktop (amd64, BuildKit), at head ca4859b:
laravel migrateruns without an npm install.laravel dev, the entrypoint installsnode_modules, and/upreturns 200 in about 10s.nodemon.target/andnode_modules/belong to the host user.docker stoptakes 0.3s.On the M1, the review fixes were rechecked:
rustfmtis writable as a non-root UID, andtini -gstops a whole process group in about 0.1s.Not tested: GPS under
laravel dev. GPS'spackage.jsononly has"dev": "vite", solaravel devwould start only Vite. GPS needs the starter'sdev,dev:serveranddev:queuescripts (ALI-2452). The GPS test above rancargo rundirectly.