Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
225 lines
12 KiB
Markdown
225 lines
12 KiB
Markdown
# Supabase Core — Local Stack
|
|
|
|
The Supabase core is a set of Docker containers managed by the **Supabase CLI**
|
|
(installed as a root devDependency — `npx supabase` works out of the box). It is
|
|
the "main docker" of the project.
|
|
|
|
## Containers
|
|
|
|
`supabase start` brings up the full local stack (project id `Convivo`):
|
|
|
|
| Container | Image | Role |
|
|
|---|---|---|
|
|
| `supabase_db_Convivo` | `supabase/postgres:17` | Postgres 17 — schema, RLS, RPCs, data |
|
|
| `supabase_auth_Convivo` | `supabase/gotrue` | Auth (QR + email login) |
|
|
| `supabase_rest_Convivo` | `supabase/postgrest` | REST API over Postgres (tables + RPCs) |
|
|
| `supabase_realtime_Convivo` | `supabase/realtime` | WebSocket realtime (leaderboard) |
|
|
| `supabase_storage_Convivo` | `supabase/storage-api` | Storage — the `materials` bucket (session material) |
|
|
| `supabase_kong_Convivo` | `supabase/kong` | **API gateway** — fronts everything on one port |
|
|
| `supabase_studio_Convivo` | `supabase/studio` | Web UI (Studio) |
|
|
| `supabase_inbucket_Convivo` | `supabase/mailpit` | Local capture service; Auth bypasses it while custom SMTP is enabled |
|
|
| `supabase_pg_meta_Convivo` | `supabase/postgres-meta` | Metadata API (used by Studio) |
|
|
| `supabase_edge_runtime_Convivo` | `supabase/edge-runtime` | Edge functions (unused in v1) |
|
|
| `supabase_vector_Convivo` | `supabase/vector` | Log shipping |
|
|
| `supabase_analytics_Convivo` | `supabase/logflare` | Analytics |
|
|
|
|
All containers share the external Docker network **`supabase_network_Convivo`**
|
|
(named `supabase_network_<project_id>`). The app sidecar joins this network — see
|
|
[docker.md](./docker.md).
|
|
|
|
## Ports
|
|
|
|
| Service | Host port | Container port | Notes |
|
|
|---|---|---|---|
|
|
| **API (Kong)** | **54321** | 8000 | The single gateway the app proxies to. **Inside the network, Kong is on 8000** — the `54321→8000` mapping is host-only. |
|
|
| Studio | 54323 | 3000 | UI — login `postgres` / `postgres` |
|
|
| Postgres | 54322 | 5432 | Direct DB — `postgres` / `postgres` |
|
|
| Mailpit UI | 54324 | 8025 | Capture-only testing when custom SMTP is disabled; currently bypassed by Auth |
|
|
| Analytics | 54327 | 4000 | Logflare |
|
|
|
|
> **Gotcha:** from *inside* the shared network (e.g. the app container), reach
|
|
> Kong at `supabase_kong_Convivo:8000`, **not** `:54321`. The `54321` port only
|
|
> exists on the host. This is why the app's nginx proxies to
|
|
> `supabase_kong_Convivo:8000` by default.
|
|
|
|
## How to run
|
|
|
|
```bash
|
|
# Start the core (creates containers + the supabase_network_Convivo network)
|
|
npm run db:start # = supabase start
|
|
|
|
# (Re)apply migrations + seed, then restart the stack
|
|
npm run db:reset # = supabase db reset (NOT `supabase reset`)
|
|
|
|
# Stop the core
|
|
npm run db:stop # = supabase stop
|
|
|
|
# Show status / URLs / keys
|
|
npx supabase status
|
|
```
|
|
|
|
- `db:reset` drops and recreates the database, applies **all** migrations in
|
|
order (`20260822000000_init.sql` → `20260823000000_admin_app.sql` →
|
|
[`20260824000000_redesign.sql`](../../supabase/migrations/20260824000000_redesign.sql),
|
|
the last of which replaces the old schema), then runs
|
|
[`seed.sql`](../../supabase/seed.sql). Use it any time you want a clean demo
|
|
state.
|
|
- Migrations and seed are **idempotent** (`on conflict ... do nothing`), so a
|
|
reset is safe to repeat.
|
|
|
|
## Config highlights (`supabase/config.toml`)
|
|
|
|
| Setting | Value | Why |
|
|
|---|---|---|
|
|
| `project_id` | `Convivo` | Names the Docker network + containers |
|
|
| `[api] port` | `54321` | Kong gateway port |
|
|
| `[db] port` | `54322` | Postgres port |
|
|
| `[studio] port` | `54323` | Studio port |
|
|
| `[auth.email] enable_confirmations` | `false` | Signup confirmation is disabled locally; explicit magic-link requests still send email |
|
|
| `[auth] jwt_expiry` | `86400` | **24-hour login** — the session JWT lives a full day |
|
|
| `[auth] site_url` | `http://127.0.0.1:3000` | The app origin |
|
|
| `[auth] additional_redirect_urls` | Exact local attendee, speaker and Admin URLs | Allows magic links to return to the requested app route |
|
|
| `[auth.rate_limit] email_sent` | `100` | Project-wide hourly budget when using custom SMTP; not an entitlement to provider capacity |
|
|
| `[auth.email] max_frequency` | `60s` | Minimum resend interval, matching the Admin UI cooldown |
|
|
| `[auth.email] otp_expiry` | `3600` | Magic links expire after one hour and are single-use |
|
|
| `[auth.email.smtp] enabled` | `true` | Explicit local opt-in to real outbound MXroute email, not Mailpit capture |
|
|
| `[auth.email.smtp] pass` | `env(CONVIVO_SMTP_PASSWORD)` | Password loaded from a private runtime environment, never committed |
|
|
| `[db.seed] sql_paths` | `["./seed.sql"]` | Seed runs on reset |
|
|
|
|
## Magic-link configuration
|
|
|
|
### Local development
|
|
|
|
The committed [config](../../supabase/config.toml) keeps `site_url` on
|
|
`http://127.0.0.1:3000` and retains the existing HTTPS localhost entry. It adds
|
|
these exact HTTP redirect destinations for **both** `localhost` and `127.0.0.1`:
|
|
|
|
- Port 3000: the app origin, `/speaker`, and `/speaker/secret`.
|
|
- Port 3001: `/auth/callback` for [Admin magic links](../frontend/admin-app.md#magic-links).
|
|
|
|
Hosts, schemes, ports and paths must match; there are no wildcard redirects.
|
|
For an alternate dev port, explicitly allow its callback URL before testing
|
|
real email links. Mocked browser tests do not exercise the Auth allowlist.
|
|
|
|
Local Auth explicitly opts into **real outbound email** through MXroute:
|
|
`heracles.mxrouting.net:465`, SMTP user and From address `[email protected]`,
|
|
sender name `Convivo APP`. GoTrue's mail transport selects implicit TLS for
|
|
port 465 and verifies the server certificate; no insecure TLS override is used.
|
|
Mailpit remains available but does not capture these externally delivered emails.
|
|
|
|
The password is referenced only as `env(CONVIVO_SMTP_PASSWORD)`. On this machine,
|
|
it is provisioned in the git-ignored `supabase/.env`, with owner-only permissions
|
|
(`0600`). Supabase CLI **2.115.0** loads dotenv files starting in `supabase/`
|
|
and then the project root, so ordinary `npm run db:start` retains SMTP delivery
|
|
without a shell export or helper. Existing process environment variables and
|
|
higher-priority dotenv files can override this value. For another checkout,
|
|
provision the same variable through a private secret store or ignored dotenv
|
|
file before starting; do not put the password in commands, tracked files,
|
|
frontend variables, screenshots, or diagnostic output.
|
|
|
|
Apply configuration changes with a local-only, volume-preserving restart:
|
|
|
|
```bash
|
|
npx supabase stop --project-id Convivo
|
|
npx supabase start
|
|
```
|
|
|
|
Expect a brief interruption of local services. Do **not** use `--no-backup`,
|
|
`--all`, or `db:reset`: no database reset, seed, or user creation is needed.
|
|
Configuration edits alone do not reconfigure a running Auth container.
|
|
For capture-only tests, set `[auth.email.smtp] enabled = false` and restart;
|
|
then inspect Mailpit at `http://127.0.0.1:54324`. Restore `enabled = true` and
|
|
restart when deliberately returning to real delivery.
|
|
|
|
Local activation was checked on 2026-10-07: normal stop/start restored the
|
|
database from backup, Auth became healthy, and its runtime SMTP host, port,
|
|
user, sender and password matched the intended configuration. The password
|
|
comparison was performed without displaying it and with no shell export,
|
|
confirming dotenv persistence. This activation check sent **no email** and does
|
|
not prove inbox delivery. The separately authorized frontend/Auth delivery check
|
|
must use an existing eligible account, verify the received link and exact
|
|
`redirect_to`, and respect the 60-second resend interval.
|
|
|
|
### Production activation (2026-10-07)
|
|
|
|
The CLI-managed VM deployment at `/home/APPE/convivo` now has verified DNS,
|
|
TLS and public routing for `convivo.appe.at` and `admin.appe.at`. Both app
|
|
origins and the exact speaker/Admin callback routes return HTTP 200; public
|
|
Auth health returns 200. `db.appe.at` has no DNS record and is not used.
|
|
See [deployment evidence and backups](../deployment.md#production-status-2026-10-07).
|
|
|
|
Production-specific changes were made only to the remote config, retaining
|
|
other settings rather than copying the local config wholesale:
|
|
|
|
- `[auth] site_url = "https://convivo.appe.at"`.
|
|
- `[auth] external_url = "https://convivo.appe.at/auth/v1"`, verified through
|
|
the attendee app's same-origin Auth proxy.
|
|
- Exact redirect additions: `https://convivo.appe.at`,
|
|
`https://admin.appe.at`, `https://convivo.appe.at/speaker`,
|
|
`https://convivo.appe.at/speaker/secret`, and
|
|
`https://admin.appe.at/auth/callback`. The pre-existing exact
|
|
`https://127.0.0.1:3000` entry was preserved; no wildcard was added.
|
|
- `[auth] jwt_issuer` explicitly retains
|
|
`http://127.0.0.1:54321/auth/v1`. This is token issuer identity, not the
|
|
public verification link. Both issuer and signing secret matched the
|
|
pre-restart Auth runtime, preserving existing session semantics.
|
|
- Custom SMTP is enabled at `heracles.mxrouting.net:465`, using implicit TLS
|
|
with verified certificates, SMTP user/From `[email protected]`, and sender
|
|
`Convivo APP`. Runtime password equality was checked without disclosure.
|
|
- `pass = "env(CONVIVO_SMTP_PASSWORD)"` loads from the private remote
|
|
`supabase/.env` (0600). Only this approved variable was provisioned over
|
|
encrypted SSH stdin; existing dotenv variables and root environment files
|
|
were preserved. No secret or local fixture dotenv was synced.
|
|
- The hourly email budget is 100, resend interval 60 seconds, and OTP expiry
|
|
3600 seconds. The standard verification-link template was retained.
|
|
|
|
The remote config passed CLI validation, then normal CLI **2.115.0** stop/start
|
|
activated it without reset, seed, data-volume deletion, or core image changes.
|
|
Both frontends were replaced from prebuilt images; the existing sidecar was
|
|
left running. Speaker RPC privileges and material write policies passed
|
|
post-restart checks, including assigned speakers registered as `staff` and
|
|
exclusion of non-session slots.
|
|
|
|
One authorized Admin magic-link request for the existing `[email protected]` account
|
|
returned HTTP 200 with account creation disabled. This verifies API acceptance
|
|
of the SMTP-backed request, not inbox receipt or full browser sign-in.
|
|
SPF/DKIM/DMARC, received-link contents, expiry/reuse rejection, and browser
|
|
screenshots remain separate verification work. Do not send additional test
|
|
emails or create production fixtures without explicit authorization.
|
|
|
|
### Rate limits and abuse boundary
|
|
|
|
The local policy is 100 Auth emails per project per hour and a 60-second resend
|
|
interval. The committed SMTP block is enabled for explicitly requested local
|
|
real delivery. Hosted Supabase's built-in
|
|
email provider has its own restrictions (currently two emails/hour and delivery
|
|
only to authorized team addresses); changing this file does not raise those
|
|
limits. Production needs custom SMTP and an explicitly configured hourly limit
|
|
that fits both provider capacity and the expected audience.
|
|
|
|
The browser cooldown and generic confirmation are UX/privacy controls, **not**
|
|
abuse enforcement. `shouldCreateUser: false` prevents this client from creating
|
|
accounts but does not prevent direct requests to public Auth endpoints, or
|
|
emailing existing non-admin users. The admin gate and database RLS control
|
|
access, not outbound mail. Enforce Auth's server-side per-user/IP/project limits,
|
|
monitor delivery failures and quota exhaustion, and evaluate CAPTCHA or a
|
|
server-side send-email policy before public rollout. Raising the hourly budget
|
|
increases spam and quota-exhaustion exposure; do not remove the resend limit.
|
|
Account-neutral UI messages do not guarantee that the underlying Auth API is
|
|
resistant to enumeration.
|
|
|
|
Current references: [passwordless email](https://supabase.com/docs/guides/auth/auth-email-passwordless),
|
|
[redirect URLs](https://supabase.com/docs/guides/auth/redirect-urls),
|
|
[custom SMTP](https://supabase.com/docs/guides/auth/auth-smtp), and
|
|
[rate limits](https://supabase.com/docs/guides/auth/rate-limits).
|
|
|
|
## Keys
|
|
|
|
| Key | Value | Where it's used |
|
|
|---|---|---|
|
|
| **Anon key** | standard local anon JWT (see `apps/convivo/.env.example`) | **Ships in the app** (public by design) |
|
|
| **Service-role key** | standard local service-role JWT | **Never in the app** — server-side only. The **sidecar** is its first consumer (see [sidecar.md](./sidecar.md)). |
|
|
|
|
The app's security model (anon key + session JWT + RLS) is documented in
|
|
[rls.md](./rls.md).
|