disclosure-bureau/infra/coolify/NEXTJS.md

85 lines
2.6 KiB
Markdown
Raw Permalink Normal View History

# Coolify — Deploy the Next.js web app
## Source
Coolify pulls from Git. Set up the repo on GitHub/GitLab/Gitea (private OK; Coolify supports deploy keys).
This repo's `/web` directory is the app root.
## Create the application
1. Coolify → **+ New Resource** → **Application****Public Git** (or Private with deploy key).
2. Repository: `git@github.com:youruser/ufo.git` (whatever you push to)
3. Branch: `main`
4. **Base directory**: `/web` ← important, the Next app isn't at the repo root
5. **Build pack**: `Nixpacks` (or `Dockerfile` if you commit one — Nixpacks is simpler for Next 15)
6. **Port**: `3000`
7. **Domain**: `disclosure.top` and `www.disclosure.top`
## Environment variables
Set in the application's **Environment Variables** tab:
```env
# Supabase (from Coolify's Supabase project page)
NEXT_PUBLIC_SUPABASE_URL=https://db.disclosure.top
NEXT_PUBLIC_SUPABASE_ANON_KEY=<paste-anon-key>
SUPABASE_SERVICE_ROLE_KEY=<paste-service-role-key>
# Anthropic (the Claude API for the chat agent)
ANTHROPIC_API_KEY=sk-ant-...
ANTHROPIC_CHAT_MODEL=claude-haiku-4-5
# Paths inside the container (we mount the wiki/ + processing/ volumes)
UFO_ROOT=/data/ufo
# Public URL (for magic-link redirects)
NEXT_PUBLIC_SITE_URL=https://disclosure.top
```
## Volume mounts — the wiki data
The Next.js app reads markdown directly from `/Users/guto/ufo/{wiki,processing,raw}`. On the VPS, mount the data dir into the container at `/data/ufo`.
In Coolify app → **Storages**:
| Source (host) | Target (container) | Mode |
|---|---|---|
| `/data/ufo/wiki` | `/data/ufo/wiki` | read-only |
| `/data/ufo/processing` | `/data/ufo/processing` | read-only |
| `/data/ufo/raw` | `/data/ufo/raw` | read-only |
**How to populate these on the VPS first time:**
```bash
# On your laptop, after pipeline finishes:
rsync -avz --progress \
/Users/guto/ufo/wiki/ \
/Users/guto/ufo/processing/ \
/Users/guto/ufo/raw/ \
root@<vps-ip>:/data/ufo/
```
Subsequent updates: just re-rsync. The container reads live (with Next.js page revalidation set appropriately).
## Deploy
Coolify pulls the repo, runs `npm install && npm run build`, then `npm run start` on port 3000.
First deploy ~5 min. Subsequent (cached layer) ~1 min.
## Verify
```bash
curl https://disclosure.top/api/documents | head -c 300
# → {"documents":[{"doc_id":"doc-059uap00011",...
```
## Continuous deploy
Coolify can listen to a Git webhook so every push to `main` triggers a rebuild. Set in Application → Webhooks.
## Next
→ [`SHARED.md`](SHARED.md) — Meilisearch + Dragonfly + Imgproxy