Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 3.91 KB

README.md

File metadata and controls

37 lines (24 loc) · 3.91 KB

docker-rust

Docker images for Rust apps, made for local development with Ingot. The PHP images live in docker-php.

Image Folder Tag
Laravel for Rust dev image laravel-rust/ ghcr.io/aliasproject/laravel-rust:dev (not published yet)

Laravel for Rust dev image

laravel-rust/Dockerfile.dev is a development image for Laravel for Rust apps (the laravel-rust crate), as Ingot runs them. Build it from its folder:

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, 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 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.

A Laravel for Rust app ships to production as one release binary, built by the app's own Dockerfile; this image is only for development.

Checks and publishing

.github/workflows/build.yml builds the image on a native amd64 runner and a native arm64 runner, on pull requests and pushes to main (except changes to Markdown files only), every Monday and on demand. On each, .github/scripts/smoke-test.sh makes a new app with laravel new --rust, runs it with laravel dev as a UID other than the image's default, and checks that /up answers, that an edit restarts the server, that the files belong to the calling user and that docker stop is prompt. Run it by hand against any local tag:

.github/scripts/smoke-test.sh laravel-rust:dev

Publishing is off. To turn it on, set the repository variable PUBLISH_IMAGES to true. Then pushes to main, the weekly rebuild and manual runs on main push each architecture's image by digest, smoke-test that exact image, and tag the pair as dev and dev-<commit> only once both pass. Pull requests never publish. After the first publish, make the laravel-rust package public in its GHCR settings, because Ingot pulls without logging in.