Let Railway build from source instead of a prebuilt image
The service ran a GHCR image pinned to a commit tag, so shipping a fix meant building and pushing an image by hand. Declare the build for Railway instead: nixpacks.toml names the same toolchain the tangled CI declares and runs `make build` unchanged, and scripts/railway-start.sh mirrors the flake entrypoint's two processes (Go API on loopback, the SvelteKit Node server on $PORT). The flake stays the canonical build; this only describes it to Railway. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
e03d429 parent: 0937d65 added
nixpacks.toml +14 -0 | new file mode 100644 | ||
| @@ -0,0 +1,14 @@ | ||
| 1 | +# Railway builds this repo from source. The flake (flake.nix) remains the | |
| 2 | +# canonical build; this file just names the same toolchain the tangled CI | |
| 3 | +# declares so `make build` runs unchanged, rather than duplicating its steps. | |
| 4 | +[phases.setup] | |
| 5 | +nixPkgs = ["go", "gcc", "gnumake", "gnugrep", "gawk", "bun", "nodejs_22"] | |
| 6 | + | |
| 7 | +[phases.install] | |
| 8 | +cmds = ["cd web && bun install"] | |
| 9 | + | |
| 10 | +[phases.build] | |
| 11 | +cmds = ["make build"] | |
| 12 | + | |
| 13 | +[start] | |
| 14 | +cmd = "./scripts/railway-start.sh" | |
| new file mode 100644 | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | +# Railway builds this repo from source. The flake (flake.nix) remains the | ||
| 2 | +# canonical build; this file just names the same toolchain the tangled CI | ||
| 3 | +# declares so `make build` runs unchanged, rather than duplicating its steps. | ||
| 4 | +[phases.setup] | ||
| 5 | +nixPkgs = ["go", "gcc", "gnumake", "gnugrep", "gawk", "bun", "nodejs_22"] | ||
| 6 | + | ||
| 7 | +[phases.install] | ||
| 8 | +cmds = ["cd web && bun install"] | ||
| 9 | + | ||
| 10 | +[phases.build] | ||
| 11 | +cmds = ["make build"] | ||
| 12 | + | ||
| 13 | +[start] | ||
| 14 | +cmd = "./scripts/railway-start.sh" | ||
added
railway.toml +7 -0 | new file mode 100644 | ||
| @@ -0,0 +1,7 @@ | ||
| 1 | +[build] | |
| 2 | +builder = "NIXPACKS" | |
| 3 | + | |
| 4 | +[deploy] | |
| 5 | +startCommand = "./scripts/railway-start.sh" | |
| 6 | +restartPolicyType = "ON_FAILURE" | |
| 7 | +restartPolicyMaxRetries = 10 | |
| new file mode 100644 | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | +[build] | ||
| 2 | +builder = "NIXPACKS" | ||
| 3 | + | ||
| 4 | +[deploy] | ||
| 5 | +startCommand = "./scripts/railway-start.sh" | ||
| 6 | +restartPolicyType = "ON_FAILURE" | ||
| 7 | +restartPolicyMaxRetries = 10 | ||
added
scripts/railway-start.sh +15 -0 | new file mode 100755 | ||
| @@ -0,0 +1,15 @@ | ||
| 1 | +#!/usr/bin/env bash | |
| 2 | +# Runs the same two processes as the flake's image entrypoint (flake.nix, | |
| 3 | +# mkEntrypoint): the Go API on loopback:8080 with the SvelteKit Node server in | |
| 4 | +# front on $PORT, proxying /api to it. Used when Railway builds from source | |
| 5 | +# instead of running the prebuilt Nix image. | |
| 6 | +set -euo pipefail | |
| 7 | + | |
| 8 | +export GLEAN_ADDR="127.0.0.1:8080" | |
| 9 | +export GLEAN_API_URL="http://127.0.0.1:8080" | |
| 10 | + | |
| 11 | +./glean & | |
| 12 | +GO_PID=$! | |
| 13 | +trap 'kill "$GO_PID" 2>/dev/null || true' INT TERM | |
| 14 | + | |
| 15 | +exec node web/build/index.js | |
| new file mode 100755 | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | +#!/usr/bin/env bash | ||
| 2 | +# Runs the same two processes as the flake's image entrypoint (flake.nix, | ||
| 3 | +# mkEntrypoint): the Go API on loopback:8080 with the SvelteKit Node server in | ||
| 4 | +# front on $PORT, proxying /api to it. Used when Railway builds from source | ||
| 5 | +# instead of running the prebuilt Nix image. | ||
| 6 | +set -euo pipefail | ||
| 7 | + | ||
| 8 | +export GLEAN_ADDR="127.0.0.1:8080" | ||
| 9 | +export GLEAN_API_URL="http://127.0.0.1:8080" | ||
| 10 | + | ||
| 11 | +./glean & | ||
| 12 | +GO_PID=$! | ||
| 13 | +trap 'kill "$GO_PID" 2>/dev/null || true' INT TERM | ||
| 14 | + | ||
| 15 | +exec node web/build/index.js | ||