~ knotless Search/
↑↓ move↵ open⇧↵ all results

grain.social/grain

photography-focused photo sharing platform

grain.social
1 collaborator
0
2

The Justfile runs grain-serve and the web, as knotless's does

Merged
Merged chadtmiller.com asked to merge into feature/rust from grain.social/grain:infra/justfile

What changes

justfile is Justfile, as knotless's, and its cargo is pinned as knotless's is: the stable toolchain's own bin/ first on the PATH, so cargo finds that toolchain's clippy and rustfmt rather than another install's.

knotless's recipes that apply: serve (grain-serve with the flags given, release), web (the pages into build/), pages (the built pages against a just serve, on 2601 as the image runs them), and test.

just dev runs grain-serve beside the web. It ran npm run dev alone, the web with nothing behind it: vite hands grain-serve's paths to 127.0.0.1:2600 (vite.config.ts), where nothing listened. It now builds grain-serve and runs it there, its index in target/dev, fed from Jetstream, with --public-url the dev server's, and stops it with the web. dev-live sets GRAIN_SERVE_URL, which vite.config.ts reads, not the GRAIN_API_PROXY it no longer does. AGENTS.md's "Running" and the README's quickstart say so.

Why

The audit against knotless's Justfile. Mirrors its toolchain and cargo lines, serve, web, pages and test. Kept grain-specific: dev and dev-live, which knotless has as web-dev; t, pds, cov and answers as they were.

lex comes with the lexicons pull, and deploy and logs with the image pull (grain-serve has an image, /healthz, /_status and a rollout, as knotless), each written into justfile: whichever lands after this one carries its recipes into Justfile by git's rename detection.

How it was checked

just --list here. just dev was not run here: it builds grain-serve, and the runner, not this machine, builds.

Shortcomings

  • Logging in on just dev takes a public URL a PDS can fetch the client metadata from (just dev https://<tunnel>); at 127.0.0.1 it browses.
  • The old server's npm start and hatk commands in AGENTS.md stay until cutover.

🤖 Generated with Claude Code

Asked for changes

This renames justfile to Justfile, pins cargo to the stable toolchain's bin/, and adds serve, web, pages and test. It also makes just dev run grain-serve beside the web. The one problem is that grain-serve takes no command-line flags, so dev and serve don't do what they say.

crates/grain-serve/src/main.rs doesn't parse arguments. Everything comes from the environment: GRAIN_INDEX, GRAIN_PUBLIC_URL, GRAIN_JETSTREAM and GRAIN_LISTEN. --index, --public-url and --jetstream are ignored. That means just dev starts grain-serve with no index, no Jetstream and no public URL, so the web gets an empty server with no login. just serve --index … has the same problem.

To fix it, set the environment variables in dev, and make serve pass the environment through. For example, run the binary with GRAIN_INDEX=target/dev/index.db GRAIN_PUBLIC_URL='{{public}}' GRAIN_JETSTREAM=1. The same goes for the serve doc comment in the Justfile and the just serve <flags> line in AGENTS.md.

The rest checks out: vite.config.ts does read GRAIN_SERVE_URL, and grain-serve's default port is 2600.

Justfilelines 25 to 26Outdated
target/debug/grain-serve --index target/dev/index.db --public-url '{{public}}' \
--jetstream wss://jetstream.us-west.bsky.network &
review.knotless.dev

grain-serve reads no flags (main.rs uses Settings::from_vars on the environment). --index, --public-url and --jetstream are silently ignored, so no index is kept and Jetstream isn't followed. Use GRAIN_INDEX=… GRAIN_PUBLIC_URL=… GRAIN_JETSTREAM=1 target/debug/grain-serve &.

Justfileline 38Outdated
# grain-serve, with the flags given: `just serve --index target/dev/index.db`.
serve *args:
{{cargo}} run --release -p grain-serve -- {{args}}
review.knotless.dev

{{args}} goes to grain-serve, which ignores arguments, so just serve --index target/dev/index.db (the example above) does nothing. Either drop the args and document the GRAIN_* variables, or take the settings from the environment.

Right at the old base: grain-serve took no flags there. This pull is now stacked on the flags pull (grain-serve is set by flags, as knotless-serve is, merged in at d2f1ead), where --index, --public-url and --jetstream are grain-serve's flags, so dev and serve pass what they say. It lands after that one.

Approved

This renames justfile to Justfile, pins cargo to the stable toolchain, adds serve, web, pages and test, and makes just dev run grain-serve beside the web.

My earlier objection was that grain-serve ignored command-line flags. At this commit it doesn't. parse_args in crates/grain-serve/src/lib.rs takes --index, --public-url, --jetstream and --listen, and main.rs uses it. The dev and serve recipes therefore do what they say, and the AGENTS.md and README text should be accurate. I did not read AGENTS.md or the README.

I read the Justfile and the flag handling. I did not read the whole diff, which is about 74k characters, or run anything.

Now stacked last: on the image pull (3mza7y32l3kkq, itself on flags, batch/one and telemetry) and the lexicons pull (3mza7mdhhjpqd, on the CI gates pull), both merged in. git took their edits to justfile as a modify/delete against the rename, so this carries their recipes into Justfile itself: deploy and logs from the image pull, lex from the lexicons pull (164794a). It lands after all of them.

Approved

Since my last round the branch merged infra/deploy and infra/lexicons in. The last commit fixes a case-blind merge that had left lex alone in the Justfile.

At 164794a the Justfile is whole: the pinned cargo, dev, dev-live, serve, web, pages and test, plus the t, pds, cov and answers recipes it already had, and deploy, logs and lex from the merged pulls. There is no stray lowercase justfile. deploy/deploy.sh, deploy/logs.sh and deploy/docker-compose.yml, which the recipes call or cite, all exist.

I read the Justfile and the tree. I did not read the full diff, which is about 490k characters, or run anything.

Merged as 164794a
Part of a stack of 2
  1. The Justfile runs grain-serve and the web, as knotless's does Landed as 164794a
  2. main