Files
solon/.env.example
CatoandClaude cb9dea9e21 Place photos drain from the database into R2, by the app itself (#621)
- With a bucket configured nothing writes place_photo_bytes: the keep is the
  bucket over the database read only. The share card reads the bucket only.
- Object keys are place-photos/v2/<sha256(file) 24 hex>/<width>: [0-9a-z/]
  only, so the public address needs no decoding. An object under the old raw
  key is copied to its current key inside the bucket on first read.
- photo-drain.ts, started from src/instrumentation.ts under a Postgres
  advisory lock: batches of 8 at about 512 kB/s (PHOTO_DRAIN_KBPS), each row
  deleted only after a HEAD shows the same length, content type and MD5;
  errors back off doubling to 15 minutes; the empty table is TRUNCATEd
  under an exclusive lock and only if still empty, and where the role may
  not, the result is measured and left to autovacuum. /api/health shows the
  progress (placePhotos). PHOTO_DRAIN=0 stops it.
- Pages draw a place photograph straight from the bucket only when a public
  base is set and the bucket is known to hold that photograph at that width
  (an index from a listing every 15 minutes plus every write); otherwise the
  route. PLACE_PHOTOS_DIRECT=0 is now only a kill switch.
- Dropping the empty table stays manual: Loki's apply-schema.sh refuses any
  pending DROP TABLE and aborts the deploy (AGENTS.md, "Photos").


Claude-Session: https://claude.ai/code/session_019MDtmvb6xi489TfZMg7n9T

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-26 14:10:56 +01:00

116 lines
5.4 KiB
Bash

# Copy to .env and fill in. Nothing here is a real secret.
# --- Required ---------------------------------------------------------------
# PostgreSQL. `npm run db:migrate` creates the schema against this.
DATABASE_URL="postgresql://solon:solon@localhost:5432/solon"
# Signs session cookies (@bitbaum/accountkit/auth). At least 32 characters in
# production. Generate with: openssl rand -base64 32. BETTER_AUTH_SECRET wins
# when both are set.
AUTH_SECRET=""
# Names a signed-in person in the public record of law proposals by a
# pseudonym per proposal (src/lib/law/amend/pseudonym.ts). Unset, the session
# secret above is used. Never change it once proposals exist: a new key gives
# everyone new names. Set it before first use if the session secret may rotate.
SOLON_PSEUDONYM_SECRET=""
# The app's own public origin. Same-origin checks on one-click acts compare
# against it, so pin it in every deployed environment.
AUTH_URL="http://localhost:3000"
NEXT_PUBLIC_APP_URL="http://localhost:3000"
# --- Continue with OrangeCat (optional) ---------------------------------------
# One way in among several; without the pair the button is not shown.
ORANGECAT_OAUTH_ISSUER="https://orangecat.ch"
ORANGECAT_OAUTH_CLIENT_ID=""
ORANGECAT_OAUTH_CLIENT_SECRET=""
# --- Account mail: password recovery and sign-in by link (optional) ----------
# Sent through @bitbaum/mail-kit (Resend). With no usable key, the sign-in
# screen shows no "Forgot your password?" and no sign-in link, only the ways
# back in that work without email (passkey, OrangeCat, writing to us). A
# placeholder key, or a sandbox sender (@resend.dev) in production, counts as
# not set.
RESEND_API_KEY=""
# Sender, `Name <addr>` or a bare address, on a domain verified in Resend.
# Unset: the fleet-conventional sender, Solon <solon@fleetcrown.orangecat.ch>.
RESEND_FROM=""
# The origin every account link is built on and must match. Unset: the
# production origin, https://solon.orangecat.ch.
NEXT_PUBLIC_SITE_URL=""
# --- Founder of a seeded organization ---------------------------------------
# An organization founded through /orgs/new seats its founder in the same step.
# Organization #1 was seeded by a migration with no human seat; its founding
# seat may be claimed ONLY by this account id (shown at /account once signed
# in; for someone whose first way in was OrangeCat it is their OrangeCat actor id). Unset, the seat is closed to everyone, /join says so in plain
# words, and /api/health lists the organization under "warnings".
SOLON_FOUNDER_ACTOR_ID=""
# --- Optional ---------------------------------------------------------------
# Watch-only treasury balances are read from a mempool.space-compatible API.
# Defaults to the public instance when unset.
MEMPOOL_API_BASE="https://mempool.space/api"
# Where `pnpm run places:import` keeps each source's raw bytes, under their
# sha256, so every imported number links back to what the source published.
# Defaults to ./data/snapshots. On the box, point it at persistent storage
# outside the release directory.
PLACES_SNAPSHOT_DIR=""
# Outbound notification of a recorded decision (OrangeCat re-verifies the
# signatures itself; this only tells it there is something new to read).
SOLON_WEBHOOK_URL=""
# Also verifies the grant Loki attaches when a project owner founds an
# organization from their project page (src/lib/loki-grant.ts). Must equal
# Loki's SOLON_WEBHOOK_SECRET. Unset, founding still works — it just cannot be
# attributed to a project.
SOLON_WEBHOOK_SECRET=""
# Bearer token the box's cron sends to /api/cron/places. Unset = the route refuses every call.
CRON_SECRET=""
# Optional. OrangeCat base URL for group lookups (src/lib/orangecat-group.ts); defaults to production.
ORANGECAT_URL=""
# Ask Solon uses the shared ai-kit model chain. Set at least one server key.
GROQ_API_KEY=""
OPENROUTER_API_KEY=""
# Web search for the law chat's research step (src/lib/law/ask/research.ts).
# Any one of these offers the model web_search and web_read; without them it
# researches in the law register only. Production copies the box's SearXNG
# settings from Causius with .github/workflows/share-search-backend.yml.
SEARXNG_URL=
SEARXNG_TOKEN=
BRAVE_SEARCH_API_KEY=
TAVILY_API_KEY=
# Photographs (Cloudflare R2, S3-compatible). On the box these five go in
# /opt/fleet/env, and the bucket gets a public domain: that is all. Each
# deploy's build (scripts/media-ensure.ts) then uploads what the bucket lacks,
# checks one photograph through MEDIA_PUBLIC_BASE and only then serves
# photographs from it. Any of them missing: photographs stay on the app, as
# before. Without the PHOTOS_S3_* four, place photographs stay in Postgres
# (place_photo_bytes).
PHOTOS_S3_ENDPOINT=""
PHOTOS_S3_BUCKET=""
PHOTOS_S3_ACCESS_KEY_ID=""
PHOTOS_S3_SECRET_ACCESS_KEY=""
# The bucket's public address (custom domain or r2.dev URL), no trailing slash.
MEDIA_PUBLIC_BASE=""
# Not for operators. NEXT_PUBLIC_MEDIA_BASE is what the build writes into
# .env.production.local once the check passes; set by hand it overrides the
# check (read at build time). With a bucket, the app moves place photographs
# out of Postgres into it by itself and serves each straight from it once it
# is there (AGENTS.md, "Photos"). Kill switches and the pace, read at run time:
# PLACE_PHOTOS_DIRECT=0 keeps every place photograph on /api/place-photo;
# PHOTO_DRAIN=0 stops the drain; PHOTO_DRAIN_KBPS is its bandwidth (512).
NEXT_PUBLIC_MEDIA_BASE=""
PLACE_PHOTOS_DIRECT=""
PHOTO_DRAIN=""
PHOTO_DRAIN_KBPS=""