|
| 1 | +--- |
| 2 | +title: "Palette content index" |
| 3 | +description: "How monolith deployments ship and mount the palette SQLite index for homepage search and cmd+K." |
| 4 | +--- |
| 5 | + |
| 6 | +# Palette content index |
| 7 | + |
| 8 | +The homepage search bar and global **cmd+K** palette query a prebuilt SQLite index (`palette.db`) produced from the repository `content/` tree. The index is a **backend artefact**: Go serves `POST /api/palette/query`; it is not bundled as a Next.js static file. |
| 9 | + |
| 10 | +## Canonical paths |
| 11 | + |
| 12 | +| Context | Path | |
| 13 | +|---------|------| |
| 14 | +| Local / CI build output | `backend/dist/palette.db` | |
| 15 | +| Baked into Docker images | `/app/palette.db` | |
| 16 | +| Runtime configuration | `SHOWCASE_PALETTE_DB=/app/palette.db` | |
| 17 | + |
| 18 | +Build the index locally: |
| 19 | + |
| 20 | +```bash |
| 21 | +cd backend |
| 22 | +go run ./cmd/palette-indexer -content ../content -out ./dist/palette.db |
| 23 | +``` |
| 24 | + |
| 25 | +## Baked into the image (recommended) |
| 26 | + |
| 27 | +`docker/Dockerfile.backend` and `docker/Dockerfile.fly` compile `palette-indexer`, run it against `/content` at **image build time**, copy `/app/palette.db` into the runtime layer, and set `SHOWCASE_PALETTE_DB=/app/palette.db`. |
| 28 | + |
| 29 | +**Implication:** changing `content/` requires rebuilding the backend (or monolith) image even when no Go source changed. |
| 30 | + |
| 31 | +Verify after deploy: |
| 32 | + |
| 33 | +```bash |
| 34 | +curl -s https://your-host/health | jq '.palette' |
| 35 | +curl -s https://your-host/api | jq '.endpoints.palette' |
| 36 | +curl -sf -X POST https://your-host/api/palette/query \ |
| 37 | + -H 'content-type: application/json' \ |
| 38 | + -d '{"q":"pkce"}' | jq '.results | length' |
| 39 | +``` |
| 40 | + |
| 41 | +In `SHOWCASE_ENV=production`, the server **refuses to start** if `SHOWCASE_PALETTE_DB` is unset or the file cannot be opened. |
| 42 | + |
| 43 | +## Mounted as a volume (self-hosted) |
| 44 | + |
| 45 | +For custom monolith deployments, build the index on a host or in CI and mount it at the canonical path: |
| 46 | + |
| 47 | +```yaml |
| 48 | +services: |
| 49 | + backend: |
| 50 | + image: ghcr.io/parlesec/protocolsoup-federation:latest |
| 51 | + environment: |
| 52 | + SHOWCASE_ENV: production |
| 53 | + SHOWCASE_PALETTE_DB: /app/palette.db |
| 54 | + volumes: |
| 55 | + - ./backend/dist/palette.db:/app/palette.db:ro |
| 56 | +``` |
| 57 | +
|
| 58 | +Rebuild the index whenever `content/` changes, then restart the backend. |
| 59 | + |
| 60 | +## Related |
| 61 | + |
| 62 | +- [Deployment models](/deploy/deployment-models/) — Model 3 (simple monolith) includes the baked index via `Dockerfile.backend` |
| 63 | +- [Environment variables](/deploy/environment-variables/) — `SHOWCASE_PALETTE_DB` |
| 64 | +- Contributor guide: palette section in the repository `CONTRIBUTING.md` |
0 commit comments