Document the Railway build instead of shipping ignored config
railway.toml, nixpacks.toml and scripts/railway-start.sh were all silently ignored by the builder, so keeping them in the repo describes a build that does not happen. The working configuration lives in the Railway service settings and environment variables; record it in docs/deploy.md, with why each piece is needed, so it can be rebuilt if the service is recreated. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ceffbf8 parent: e03d429 added
docs/deploy.md +39 -0 | new file mode 100644 | ||
| @@ -0,0 +1,39 @@ | ||
| 1 | +# Deploying | |
| 2 | + | |
| 3 | +The canonical build is the Nix flake (`flake.nix`): `nix build .#image` produces | |
| 4 | +the container image, and `make image-push IMAGE=<ref>` publishes it. That path | |
| 5 | +still works and is the reproducible one. | |
| 6 | + | |
| 7 | +## Railway (production) | |
| 8 | + | |
| 9 | +The `glean` service in the `glean` project builds **from source** on | |
| 10 | +`railway up`, rather than running a prebuilt image. Railway ignores in-repo | |
| 11 | +build config here — `railway.toml`, `nixpacks.toml` and a start script in | |
| 12 | +`scripts/` were all silently skipped — so the configuration lives in the | |
| 13 | +service settings and environment variables instead: | |
| 14 | + | |
| 15 | +| Setting | Value | | |
| 16 | +|---|---| | |
| 17 | +| Builder | `NIXPACKS` (the Railpack default cannot build this repo) | | |
| 18 | +| Build command | `cd web && bun install && cd .. && make build` | | |
| 19 | +| Start command | `sh -c "GLEAN_API_URL=http://127.0.0.1:8080 GLEAN_ADDR=127.0.0.1:8080 /app/glean & exec node /app/web/build/index.js"` | | |
| 20 | +| `NIXPACKS_PKGS` | `bun nodejs gnumake gcc gawk gnugrep` | | |
| 21 | +| `CGO_ENABLED` | `1` | | |
| 22 | + | |
| 23 | +Notes on why each is needed: | |
| 24 | + | |
| 25 | +- **`CGO_ENABLED=1`** — `sqlite-vec-go-bindings/cgo` and `mattn/go-sqlite3` are | |
| 26 | + cgo packages. The builder defaults to cgo off, which fails with "build | |
| 27 | + constraints exclude all Go files". | |
| 28 | +- **`NIXPACKS_PKGS`** — the Go provider installs only Go. The frontend needs | |
| 29 | + `bun` to build and `nodejs` to serve; `make build` needs make/grep/awk. This | |
| 30 | + mirrors the dependency list in `.tangled/workflows`. Use `nodejs`, not | |
| 31 | + `nodejs_22`: the pinned nixpkgs has no such attribute. | |
| 32 | +- **Build command** — the builder's default `go build -o out` skips both the | |
| 33 | + `fts5` tag and the SvelteKit build. `make build` does both. | |
| 34 | +- **Start command** — mirrors the flake's `mkEntrypoint`: the Go API on | |
| 35 | + loopback:8080 with the SvelteKit Node server in front on `$PORT`. It is | |
| 36 | + inline rather than a script file because the runtime image does not carry | |
| 37 | + `scripts/`. | |
| 38 | + | |
| 39 | +Deploy with `railway up` from the repo root. | |
| new file mode 100644 | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | +# Deploying | ||
| 2 | + | ||
| 3 | +The canonical build is the Nix flake (`flake.nix`): `nix build .#image` produces | ||
| 4 | +the container image, and `make image-push IMAGE=<ref>` publishes it. That path | ||
| 5 | +still works and is the reproducible one. | ||
| 6 | + | ||
| 7 | +## Railway (production) | ||
| 8 | + | ||
| 9 | +The `glean` service in the `glean` project builds **from source** on | ||
| 10 | +`railway up`, rather than running a prebuilt image. Railway ignores in-repo | ||
| 11 | +build config here — `railway.toml`, `nixpacks.toml` and a start script in | ||
| 12 | +`scripts/` were all silently skipped — so the configuration lives in the | ||
| 13 | +service settings and environment variables instead: | ||
| 14 | + | ||
| 15 | +| Setting | Value | | ||
| 16 | +|---|---| | ||
| 17 | +| Builder | `NIXPACKS` (the Railpack default cannot build this repo) | | ||
| 18 | +| Build command | `cd web && bun install && cd .. && make build` | | ||
| 19 | +| Start command | `sh -c "GLEAN_API_URL=http://127.0.0.1:8080 GLEAN_ADDR=127.0.0.1:8080 /app/glean & exec node /app/web/build/index.js"` | | ||
| 20 | +| `NIXPACKS_PKGS` | `bun nodejs gnumake gcc gawk gnugrep` | | ||
| 21 | +| `CGO_ENABLED` | `1` | | ||
| 22 | + | ||
| 23 | +Notes on why each is needed: | ||
| 24 | + | ||
| 25 | +- **`CGO_ENABLED=1`** — `sqlite-vec-go-bindings/cgo` and `mattn/go-sqlite3` are | ||
| 26 | + cgo packages. The builder defaults to cgo off, which fails with "build | ||
| 27 | + constraints exclude all Go files". | ||
| 28 | +- **`NIXPACKS_PKGS`** — the Go provider installs only Go. The frontend needs | ||
| 29 | + `bun` to build and `nodejs` to serve; `make build` needs make/grep/awk. This | ||
| 30 | + mirrors the dependency list in `.tangled/workflows`. Use `nodejs`, not | ||
| 31 | + `nodejs_22`: the pinned nixpkgs has no such attribute. | ||
| 32 | +- **Build command** — the builder's default `go build -o out` skips both the | ||
| 33 | + `fts5` tag and the SvelteKit build. `make build` does both. | ||
| 34 | +- **Start command** — mirrors the flake's `mkEntrypoint`: the Go API on | ||
| 35 | + loopback:8080 with the SvelteKit Node server in front on `$PORT`. It is | ||
| 36 | + inline rather than a script file because the runtime image does not carry | ||
| 37 | + `scripts/`. | ||
| 38 | + | ||
| 39 | +Deploy with `railway up` from the repo root. | ||
deleted
nixpacks.toml +0 -14 | deleted file mode 100644 | ||
| @@ -1,14 +0,0 @@ | ||
| 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" | |
| deleted file mode 100644 | |||
| @@ -1,14 +0,0 @@ | |||
| 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" | ||
deleted
railway.toml +0 -7 | deleted file mode 100644 | ||
| @@ -1,7 +0,0 @@ | ||
| 1 | -[build] | |
| 2 | -builder = "NIXPACKS" | |
| 3 | - | |
| 4 | -[deploy] | |
| 5 | -startCommand = "./scripts/railway-start.sh" | |
| 6 | -restartPolicyType = "ON_FAILURE" | |
| 7 | -restartPolicyMaxRetries = 10 | |
| deleted file mode 100644 | |||
| @@ -1,7 +0,0 @@ | |||
| 1 | -[build] | ||
| 2 | -builder = "NIXPACKS" | ||
| 3 | - | ||
| 4 | -[deploy] | ||
| 5 | -startCommand = "./scripts/railway-start.sh" | ||
| 6 | -restartPolicyType = "ON_FAILURE" | ||
| 7 | -restartPolicyMaxRetries = 10 | ||
deleted
scripts/railway-start.sh +0 -15 | deleted file mode 100755 | ||
| @@ -1,15 +0,0 @@ | ||
| 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 | |
| deleted file mode 100755 | |||
| @@ -1,15 +0,0 @@ | |||
| 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 | ||