From b9c270d913d4f9a8fa73af151fceec95793ac670 Mon Sep 17 00:00:00 2001 From: Michael Aguiar Date: Tue, 1 Dec 2026 15:50:38 -0700 Subject: [PATCH 1/5] Add a Laravel for Rust dev image (draft, not built yet) (ALI-2447) 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. --- laravel-rust/Dockerfile.dev | 83 +++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 laravel-rust/Dockerfile.dev diff --git a/laravel-rust/Dockerfile.dev b/laravel-rust/Dockerfile.dev new file mode 100644 index 0000000..1e1acfe --- /dev/null +++ b/laravel-rust/Dockerfile.dev @@ -0,0 +1,83 @@ +# syntax=docker/dockerfile:1 +# +# Development image for Laravel for Rust apps (the laravel-rust crate), as +# Ingot runs them: the project is bind-mounted at /app and `laravel dev` +# serves it, rebuilding and restarting on every change to src/, Cargo.toml, +# Cargo.lock or .env, with Vite for templates and assets. +# +# Not for production: a Laravel for Rust app ships as one release binary +# (see the app's own Dockerfile). +ARG RUST_VERSION=1.99 +ARG NODE_VERSION=24 +FROM node:${NODE_VERSION}-bookworm-slim AS node + +FROM rust:${RUST_VERSION}-bookworm + +LABEL maintainer="Michael Aguiar " + +# The Laravel CLI (`laravel dev`, `laravel migrate`, ...). Pinned to a +# release of laravel/cli-releases and checked against its published +# sha256.sum, instead of piping laravel.com/install.sh to a shell. There +# are only glibc builds for arm64, which is why this image is Debian, not +# Alpine. +ARG LARAVEL_CLI_VERSION=0.3.0 +ARG LARAVEL_CLI_SHA256_AMD64=b9271c4f929a24875c915681fe0d004139e004d4d4ade95c743569066b98ce69 +ARG LARAVEL_CLI_SHA256_ARM64=005faf367ee41acd30b39bf7e86654fa37474c67ad662ec86392e48932840525 +ARG TARGETARCH + +# Node and npm for Vite, copied from the official image (same Debian +# release, so the same glibc). +COPY --from=node /usr/local/bin/node /usr/local/bin/node +COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules + +RUN set -eux; \ + ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm; \ + ln -s ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx; \ + node --version; npm --version; \ + \ + case "$TARGETARCH" in \ + amd64) target=x86_64-unknown-linux-gnu; sha256=$LARAVEL_CLI_SHA256_AMD64 ;; \ + arm64) target=aarch64-unknown-linux-gnu; sha256=$LARAVEL_CLI_SHA256_ARM64 ;; \ + *) echo "unsupported architecture: $TARGETARCH" >&2; exit 1 ;; \ + esac; \ + archive="laravel-cli-$target.tar.xz"; \ + curl -fsSLo "/tmp/$archive" "https://github.com/laravel/cli-releases/releases/download/v$LARAVEL_CLI_VERSION/$archive"; \ + echo "$sha256 /tmp/$archive" | sha256sum -c -; \ + mkdir /tmp/laravel-cli; \ + tar -xJf "/tmp/$archive" -C /tmp/laravel-cli; \ + install -m 0755 "$(find /tmp/laravel-cli -type f -name laravel | head -n1)" /usr/local/bin/laravel; \ + rm -rf /tmp/laravel-cli "/tmp/$archive"; \ + laravel --version; \ + \ + rustup component add rustfmt clippy; \ + \ + # Ingot mounts shared volumes at these folders so downloaded crates and + # compiled dependencies outlive the container (new Laravel for Rust apps + # set Cargo's build-dir to {cargo-cache-home}/build/laravel-rust). A new + # volume takes the ownership and mode of the folder it is mounted on, + # and the container runs as the host user's UID in group 0, so the + # folders must exist here, writable by group 0. + mkdir -p "$CARGO_HOME/registry" "$CARGO_HOME/git" "$CARGO_HOME/build"; \ + chgrp -R 0 "$CARGO_HOME" "$RUSTUP_HOME"; \ + chmod -R g+rwX "$CARGO_HOME" "$RUSTUP_HOME"; \ + \ + # A home for whatever UID the container runs as: npm's cache and the + # Laravel CLI's config live under $HOME. + mkdir -p /home/app; \ + chgrp 0 /home/app; \ + chmod 2775 /home/app + +ENV HOME=/home/app \ + SERVER_HOST=0.0.0.0 \ + SERVER_PORT=80 + +WORKDIR /app + +# Ingot runs the container as the host user's UID in group 0, so files the +# app writes to /app (target/, public/build/, storage/) belong to that +# user. Without Ingot, pass --user "$(id -u):0" for the same. +USER 1000:0 + +EXPOSE 80 + +CMD ["laravel", "dev"] From 186a9991407ab1002a44a30c9590e511a30bc110 Mon Sep 17 00:00:00 2001 From: Michael Aguiar Date: Tue, 1 Dec 2026 16:07:02 -0700 Subject: [PATCH 2/5] Laravel for Rust dev image: entrypoint, legacy-builder support, README (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. --- README.md | 17 +++++++++++++++++ laravel-rust/Dockerfile.dev | 16 ++++++++++++---- laravel-rust/docker-entrypoint | 18 ++++++++++++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) create mode 100755 laravel-rust/docker-entrypoint diff --git a/README.md b/README.md index f8e2b5c..2c4d9db 100644 --- a/README.md +++ b/README.md @@ -87,3 +87,20 @@ docker run -e WORDPRESS_VCS_CHECKOUT=1 ghcr.io/aliasproject/php:8.4-frankenphp-w It is unset by default, and only the exact value `1` turns it on. Every frankenphp image (base, `dev`, `wordpress` and `wordpress-dev`, so a WordPress site on the base image is covered too) sets PHP's `auto_prepend_file` to `/usr/local/share/php-prepend/wordpress-vcs-checkout.php`, in `php.ini`. The file is root-owned, and adds `__return_true` to WordPress's `automatic_updates_is_vcs_checkout` filter before WordPress loads (WordPress 4.7 or newer). That covers web requests, WP-Cron when a web request runs it, and WP-CLI run with `docker exec` in the frankenphp container (a system cron calling `docker exec php wp-cli.phar cron event run`, for example; the images don't ship WP-CLI itself). Only WP-CLI in a separate CLI container needs the image built from `php/8.4/cli/Dockerfile.wordpress`, which carries the same file; CI doesn't build or publish that image. With the variable unset the file does nothing. With it set, the only effect on code that isn't WordPress is a global `$wp_filter` array with that one entry. Manual updates from wp-admin or `wp core update` still work. If `getenv` is in `PHP_DISABLE_FUNCTIONS`, the file can't read the variable and does nothing. A derived image that sets its own `auto_prepend_file` (a Wordfence WAF, say) replaces this one, whether it edits the `auto_prepend_file` line in `php.ini`, appends its own line there or adds any `conf.d` file: PHP reads `conf.d` after `php.ini`, and the last setting wins. When `PHP_OPEN_BASEDIR` is set, the frankenphp images add `/usr/local/share/php-prepend/` to it, because PHP refuses every request whose prepend file it can't open. An image that sets `open_basedir` some other way (its own `conf.d` file) has to add that directory itself. + +## Laravel for Rust dev image + +`laravel-rust/Dockerfile.dev` is a development image for [Laravel for Rust](https://laravel.com/rust/docs) apps (the `laravel-rust` crate), as [Ingot](https://github.com/aliasproject/ingot) runs them. It isn't built by CI or published yet. Build it from its folder: + +```sh +docker build -f laravel-rust/Dockerfile.dev -t laravel-rust:dev laravel-rust +``` + +It has Rust 1.99 with `rustfmt` and `clippy`, Node 24, and the Laravel CLI 0.3.0. The CLI is a pinned release archive, checked against the release's `sha256.sum`. The image is Debian-based because the CLI has no Alpine build for arm64. + +The project is mounted at `/app`, and the container runs `laravel dev`, which runs the app's `npm run dev`. In an app made with `laravel new`, that script runs three processes: the server, which `nodemon` restarts with `cargo run` when `src/`, `Cargo.toml`, `Cargo.lock` or `.env` changes; a queue worker; and Vite. If `node_modules` is missing, the entrypoint installs it first. After a lockfile change, run `npm ci` in the container yourself. + +- **Address:** the app listens on `SERVER_HOST=0.0.0.0` and `SERVER_PORT=80`. Real environment variables take precedence over the app's `.env`. +- **User:** run the container as your own UID in group 0 (`--user "$(id -u):0"`), so the files it writes to `/app` (`target/`, `node_modules/`, `public/build/`) belong to you. `HOME` is `/home/app`, writable by group 0. +- **Caches:** `CARGO_HOME` is `/usr/local/cargo`. Mount volumes at its `registry`, `git` and `build` folders to keep downloaded crates and compiled dependencies across containers. New apps compile into `build/`, through Cargo's `build-dir`. The folders exist in the image, writable by group 0, so a new volume mounted there is writable too. Don't mount a volume over `CARGO_HOME` itself: it also holds `cargo` and `rustc`, which the volume would pin to an old version. +- **Console commands:** use `laravel migrate`, `laravel route:list` and so on. diff --git a/laravel-rust/Dockerfile.dev b/laravel-rust/Dockerfile.dev index 1e1acfe..722120b 100644 --- a/laravel-rust/Dockerfile.dev +++ b/laravel-rust/Dockerfile.dev @@ -2,8 +2,11 @@ # # Development image for Laravel for Rust apps (the laravel-rust crate), as # Ingot runs them: the project is bind-mounted at /app and `laravel dev` -# serves it, rebuilding and restarting on every change to src/, Cargo.toml, -# Cargo.lock or .env, with Vite for templates and assets. +# serves it. That command runs the app's `npm run dev`, which in a new +# Laravel for Rust app restarts `cargo run` on every change to src/, +# Cargo.toml, Cargo.lock or .env, runs a queue worker, and runs Vite. +# +# Build context: this folder. # # Not for production: a Laravel for Rust app ships as one release binary # (see the app's own Dockerfile). @@ -35,10 +38,12 @@ RUN set -eux; \ ln -s ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx; \ node --version; npm --version; \ \ - case "$TARGETARCH" in \ + # TARGETARCH is only set by BuildKit; the legacy builder leaves it empty. + arch="${TARGETARCH:-$(dpkg --print-architecture)}"; \ + case "$arch" in \ amd64) target=x86_64-unknown-linux-gnu; sha256=$LARAVEL_CLI_SHA256_AMD64 ;; \ arm64) target=aarch64-unknown-linux-gnu; sha256=$LARAVEL_CLI_SHA256_ARM64 ;; \ - *) echo "unsupported architecture: $TARGETARCH" >&2; exit 1 ;; \ + *) echo "unsupported architecture: $arch" >&2; exit 1 ;; \ esac; \ archive="laravel-cli-$target.tar.xz"; \ curl -fsSLo "/tmp/$archive" "https://github.com/laravel/cli-releases/releases/download/v$LARAVEL_CLI_VERSION/$archive"; \ @@ -78,6 +83,9 @@ WORKDIR /app # user. Without Ingot, pass --user "$(id -u):0" for the same. USER 1000:0 +COPY docker-entrypoint /usr/local/bin/docker-entrypoint + EXPOSE 80 +ENTRYPOINT ["docker-entrypoint"] CMD ["laravel", "dev"] diff --git a/laravel-rust/docker-entrypoint b/laravel-rust/docker-entrypoint new file mode 100755 index 0000000..8dcb5e5 --- /dev/null +++ b/laravel-rust/docker-entrypoint @@ -0,0 +1,18 @@ +#!/bin/sh +# `laravel dev` runs the app's `npm run dev` (server, queue worker and Vite +# under concurrently and nodemon), so it needs node_modules, and nothing +# else installs them in a project that was cloned rather than made with +# `laravel new`. Install them once, when they're missing; after a lockfile +# change, run `npm ci` in the container yourself. +set -e + +if [ -f package.json ] && [ ! -d node_modules ]; then + echo "docker-entrypoint: node_modules is missing, installing it" >&2 + if [ -f package-lock.json ]; then + npm ci --no-audit --no-fund + else + npm install --no-audit --no-fund + fi +fi + +exec "$@" From ef04d136492e37071d10958922071d323ff537cc Mon Sep 17 00:00:00 2001 From: Michael Aguiar Date: Tue, 1 Dec 2026 16:09:30 -0700 Subject: [PATCH 3/5] Only touch the Cargo cache folders' permissions; note Linux-built node_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. --- README.md | 2 +- laravel-rust/Dockerfile.dev | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2c4d9db..b6300ec 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ docker build -f laravel-rust/Dockerfile.dev -t laravel-rust:dev laravel-rust It has Rust 1.99 with `rustfmt` and `clippy`, Node 24, and the Laravel CLI 0.3.0. The CLI is a pinned release archive, checked against the release's `sha256.sum`. The image is Debian-based because the CLI has no Alpine build for arm64. -The project is mounted at `/app`, and the container runs `laravel dev`, which runs the app's `npm run dev`. In an app made with `laravel new`, that script runs three processes: the server, which `nodemon` restarts with `cargo run` when `src/`, `Cargo.toml`, `Cargo.lock` or `.env` changes; a queue worker; and Vite. If `node_modules` is missing, the entrypoint installs it first. After a lockfile change, run `npm ci` in the container yourself. +The project is mounted at `/app`, and the container runs `laravel dev`, which runs the app's `npm run dev`. In an app made with `laravel new`, that script runs three processes: the server, which `nodemon` restarts with `cargo run` when `src/`, `Cargo.toml`, `Cargo.lock` or `.env` changes; a queue worker; and Vite. If `node_modules` is missing, the entrypoint installs it first. After a lockfile change, run `npm ci` in the container yourself. Those packages are built for Linux. On macOS or Windows, where `/app` is your host folder, a host-side `npm run dev` then fails on them, so run npm in the container, or run `npm ci` again on the host before using it there. - **Address:** the app listens on `SERVER_HOST=0.0.0.0` and `SERVER_PORT=80`. Real environment variables take precedence over the app's `.env`. - **User:** run the container as your own UID in group 0 (`--user "$(id -u):0"`), so the files it writes to `/app` (`target/`, `node_modules/`, `public/build/`) belong to you. `HOME` is `/home/app`, writable by group 0. diff --git a/laravel-rust/Dockerfile.dev b/laravel-rust/Dockerfile.dev index 722120b..91cef62 100644 --- a/laravel-rust/Dockerfile.dev +++ b/laravel-rust/Dockerfile.dev @@ -61,10 +61,11 @@ RUN set -eux; \ # set Cargo's build-dir to {cargo-cache-home}/build/laravel-rust). A new # volume takes the ownership and mode of the folder it is mounted on, # and the container runs as the host user's UID in group 0, so the - # folders must exist here, writable by group 0. + # folders must exist here, writable by group 0. (The rest of CARGO_HOME + # and RUSTUP_HOME is already world-writable in the official image.) mkdir -p "$CARGO_HOME/registry" "$CARGO_HOME/git" "$CARGO_HOME/build"; \ - chgrp -R 0 "$CARGO_HOME" "$RUSTUP_HOME"; \ - chmod -R g+rwX "$CARGO_HOME" "$RUSTUP_HOME"; \ + chgrp 0 "$CARGO_HOME/registry" "$CARGO_HOME/git" "$CARGO_HOME/build"; \ + chmod 2775 "$CARGO_HOME/registry" "$CARGO_HOME/git" "$CARGO_HOME/build"; \ \ # A home for whatever UID the container runs as: npm's cache and the # Laravel CLI's config live under $HOME. From 9f305fcec95c519039f156a2a141f62113b549a8 Mon Sep 17 00:00:00 2001 From: Michael Aguiar Date: Tue, 1 Dec 2026 16:14:13 -0700 Subject: [PATCH 4/5] Keep RUSTUP_HOME writable, run under tini, install node_modules only 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. --- README.md | 3 ++- laravel-rust/Dockerfile.dev | 15 +++++++++++++-- laravel-rust/docker-entrypoint | 10 ++++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b6300ec..51ea09d 100644 --- a/README.md +++ b/README.md @@ -98,9 +98,10 @@ docker build -f laravel-rust/Dockerfile.dev -t laravel-rust:dev laravel-rust It has Rust 1.99 with `rustfmt` and `clippy`, Node 24, and the Laravel CLI 0.3.0. The CLI is a pinned release archive, checked against the release's `sha256.sum`. The image is Debian-based because the CLI has no Alpine build for arm64. -The project is mounted at `/app`, and the container runs `laravel dev`, which runs the app's `npm run dev`. In an app made with `laravel new`, that script runs three processes: the server, which `nodemon` restarts with `cargo run` when `src/`, `Cargo.toml`, `Cargo.lock` or `.env` changes; a queue worker; and Vite. If `node_modules` is missing, the entrypoint installs it first. After a lockfile change, run `npm ci` in the container yourself. Those packages are built for Linux. On macOS or Windows, where `/app` is your host folder, a host-side `npm run dev` then fails on them, so run npm in the container, or run `npm ci` again on the host before using it there. +The project is mounted at `/app`, and the container runs `laravel dev`, which runs the app's `npm run dev`. In an app made with `laravel new`, that script runs three processes: the server, which `nodemon` restarts with `cargo run` when `src/`, `Cargo.toml`, `Cargo.lock` or `.env` changes; a queue worker; and Vite. If `node_modules` isn't installed, `laravel dev` installs it first (other commands, such as `laravel migrate`, don't). After a lockfile change, run `npm ci` in the container yourself. Those packages are built for Linux. On macOS or Windows, where `/app` is your host folder, a host-side `npm run dev` then fails on them, so run npm in the container, or run `npm ci` again on the host before using it there. - **Address:** the app listens on `SERVER_HOST=0.0.0.0` and `SERVER_PORT=80`. Real environment variables take precedence over the app's `.env`. - **User:** run the container as your own UID in group 0 (`--user "$(id -u):0"`), so the files it writes to `/app` (`target/`, `node_modules/`, `public/build/`) belong to you. `HOME` is `/home/app`, writable by group 0. - **Caches:** `CARGO_HOME` is `/usr/local/cargo`. Mount volumes at its `registry`, `git` and `build` folders to keep downloaded crates and compiled dependencies across containers. New apps compile into `build/`, through Cargo's `build-dir`. The folders exist in the image, writable by group 0, so a new volume mounted there is writable too. Don't mount a volume over `CARGO_HOME` itself: it also holds `cargo` and `rustc`, which the volume would pin to an old version. +- **Stopping:** `tini` is PID 1, so `docker stop` reaches `laravel dev` and the processes it runs. - **Console commands:** use `laravel migrate`, `laravel route:list` and so on. diff --git a/laravel-rust/Dockerfile.dev b/laravel-rust/Dockerfile.dev index 91cef62..4d2db65 100644 --- a/laravel-rust/Dockerfile.dev +++ b/laravel-rust/Dockerfile.dev @@ -55,6 +55,17 @@ RUN set -eux; \ laravel --version; \ \ rustup component add rustfmt clippy; \ + # The official image leaves RUSTUP_HOME world-writable so any user can + # install a toolchain or component (an app's rust-toolchain.toml can ask + # for one); keep that true for what was just added as root. + chmod -R a+w "$RUSTUP_HOME"; \ + \ + # tini runs as PID 1, so `docker stop` (and Ingot's idle stop) reaches + # laravel dev and its nodemon and cargo children instead of waiting out + # the timeout and killing them mid-build. + apt-get update; \ + apt-get install -y --no-install-recommends tini; \ + rm -rf /var/lib/apt/lists/*; \ \ # Ingot mounts shared volumes at these folders so downloaded crates and # compiled dependencies outlive the container (new Laravel for Rust apps @@ -62,7 +73,7 @@ RUN set -eux; \ # volume takes the ownership and mode of the folder it is mounted on, # and the container runs as the host user's UID in group 0, so the # folders must exist here, writable by group 0. (The rest of CARGO_HOME - # and RUSTUP_HOME is already world-writable in the official image.) + # is already world-writable in the official image.) mkdir -p "$CARGO_HOME/registry" "$CARGO_HOME/git" "$CARGO_HOME/build"; \ chgrp 0 "$CARGO_HOME/registry" "$CARGO_HOME/git" "$CARGO_HOME/build"; \ chmod 2775 "$CARGO_HOME/registry" "$CARGO_HOME/git" "$CARGO_HOME/build"; \ @@ -88,5 +99,5 @@ COPY docker-entrypoint /usr/local/bin/docker-entrypoint EXPOSE 80 -ENTRYPOINT ["docker-entrypoint"] +ENTRYPOINT ["tini", "--", "docker-entrypoint"] CMD ["laravel", "dev"] diff --git a/laravel-rust/docker-entrypoint b/laravel-rust/docker-entrypoint index 8dcb5e5..52ea2b1 100755 --- a/laravel-rust/docker-entrypoint +++ b/laravel-rust/docker-entrypoint @@ -2,12 +2,14 @@ # `laravel dev` runs the app's `npm run dev` (server, queue worker and Vite # under concurrently and nodemon), so it needs node_modules, and nothing # else installs them in a project that was cloned rather than made with -# `laravel new`. Install them once, when they're missing; after a lockfile -# change, run `npm ci` in the container yourself. +# `laravel new`. Install them before `laravel dev` when npm hasn't (no +# node_modules/.package-lock.json, which npm writes once an install has +# finished). Other commands (`laravel migrate`, a shell) start as they are. +# After a lockfile change, run `npm ci` in the container yourself. set -e -if [ -f package.json ] && [ ! -d node_modules ]; then - echo "docker-entrypoint: node_modules is missing, installing it" >&2 +if [ "$1" = laravel ] && [ "$2" = dev ] && [ -f package.json ] && [ ! -f node_modules/.package-lock.json ]; then + echo "docker-entrypoint: node_modules isn't installed, installing it" >&2 if [ -f package-lock.json ]; then npm ci --no-audit --no-fund else From ca4859b2da8ef2dadece0565a0731b323fac0361 Mon Sep 17 00:00:00 2001 From: Michael Aguiar Date: Tue, 1 Dec 2026 16:16:48 -0700 Subject: [PATCH 5/5] chmod only RUSTUP_HOME files that need it; tini signals the process group (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. --- README.md | 4 ++-- laravel-rust/Dockerfile.dev | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 51ea09d..2b37f7b 100644 --- a/README.md +++ b/README.md @@ -98,10 +98,10 @@ docker build -f laravel-rust/Dockerfile.dev -t laravel-rust:dev laravel-rust It has Rust 1.99 with `rustfmt` and `clippy`, Node 24, and the Laravel CLI 0.3.0. The CLI is a pinned release archive, checked against the release's `sha256.sum`. The image is Debian-based because the CLI has no Alpine build for arm64. -The project is mounted at `/app`, and the container runs `laravel dev`, which runs the app's `npm run dev`. In an app made with `laravel new`, that script runs three processes: the server, which `nodemon` restarts with `cargo run` when `src/`, `Cargo.toml`, `Cargo.lock` or `.env` changes; a queue worker; and Vite. If `node_modules` isn't installed, `laravel dev` installs it first (other commands, such as `laravel migrate`, don't). After a lockfile change, run `npm ci` in the container yourself. Those packages are built for Linux. On macOS or Windows, where `/app` is your host folder, a host-side `npm run dev` then fails on them, so run npm in the container, or run `npm ci` again on the host before using it there. +The project is mounted at `/app`, and the container runs `laravel dev`, which runs the app's `npm run dev`. In an app made with `laravel new`, that script runs three processes: the server, which `nodemon` restarts with `cargo run` when `src/`, `Cargo.toml`, `Cargo.lock` or `.env` changes; a queue worker; and Vite. If `node_modules` isn't installed, the container's own `laravel dev` command installs it first. Other commands, such as `laravel migrate`, don't, and neither does `laravel dev` wrapped in a shell or with options before `dev`. After a lockfile change, run `npm ci` in the container yourself. Those packages are built for Linux. On macOS or Windows, where `/app` is your host folder, a host-side `npm run dev` then fails on them, so run npm in the container, or run `npm ci` again on the host before using it there. - **Address:** the app listens on `SERVER_HOST=0.0.0.0` and `SERVER_PORT=80`. Real environment variables take precedence over the app's `.env`. - **User:** run the container as your own UID in group 0 (`--user "$(id -u):0"`), so the files it writes to `/app` (`target/`, `node_modules/`, `public/build/`) belong to you. `HOME` is `/home/app`, writable by group 0. - **Caches:** `CARGO_HOME` is `/usr/local/cargo`. Mount volumes at its `registry`, `git` and `build` folders to keep downloaded crates and compiled dependencies across containers. New apps compile into `build/`, through Cargo's `build-dir`. The folders exist in the image, writable by group 0, so a new volume mounted there is writable too. Don't mount a volume over `CARGO_HOME` itself: it also holds `cargo` and `rustc`, which the volume would pin to an old version. -- **Stopping:** `tini` is PID 1, so `docker stop` reaches `laravel dev` and the processes it runs. +- **Stopping:** `tini` is PID 1 and passes `docker stop`'s signal to the whole process group, so `laravel dev` and the processes it runs stop promptly. - **Console commands:** use `laravel migrate`, `laravel route:list` and so on. diff --git a/laravel-rust/Dockerfile.dev b/laravel-rust/Dockerfile.dev index 4d2db65..5e87a4d 100644 --- a/laravel-rust/Dockerfile.dev +++ b/laravel-rust/Dockerfile.dev @@ -57,12 +57,15 @@ RUN set -eux; \ rustup component add rustfmt clippy; \ # The official image leaves RUSTUP_HOME world-writable so any user can # install a toolchain or component (an app's rust-toolchain.toml can ask - # for one); keep that true for what was just added as root. - chmod -R a+w "$RUSTUP_HOME"; \ + # for one); keep that true for what was just added as root. Only the + # files that aren't yet: a chmod on the rest could copy the whole + # toolchain into this layer. + find "$RUSTUP_HOME" ! -perm -o+w -exec chmod a+w {} +; \ \ - # tini runs as PID 1, so `docker stop` (and Ingot's idle stop) reaches - # laravel dev and its nodemon and cargo children instead of waiting out - # the timeout and killing them mid-build. + # tini runs as PID 1 and (with -g) passes signals to the whole process + # group, so `docker stop` (and Ingot's idle stop) reaches laravel dev + # and its nodemon and cargo children instead of waiting out the timeout + # and killing them mid-build. apt-get update; \ apt-get install -y --no-install-recommends tini; \ rm -rf /var/lib/apt/lists/*; \ @@ -99,5 +102,5 @@ COPY docker-entrypoint /usr/local/bin/docker-entrypoint EXPOSE 80 -ENTRYPOINT ["tini", "--", "docker-entrypoint"] +ENTRYPOINT ["tini", "-g", "--", "docker-entrypoint"] CMD ["laravel", "dev"]