Phase 10, part 9: the server package

compose.server.yaml runs Supermarket behind Caddy (HTTPS from Let's
Encrypt, Caddy's own CA or the team's), with Postgres on an internal
network and a nightly pg_dump kept two weeks. install-server.sh asks for
the domain, certificate and mail server, makes the secret key and database
password, starts it all and prints the setup link. Settings → Backups lists
the dumps on a server, and how the operator restores one. Checked end to
end in Docker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 09:37:34 -07:00
co-authored by Claude Opus 5.5
parent c8964cec12
commit da16736fb4
15 changed files with 532 additions and 17 deletions
+53 -1
View File
@@ -210,10 +210,62 @@ The old terminal app used `http://localhost:8080/callback`; you can remove that
## Security
- The port is published on `127.0.0.1` only, so other machines can't reach it, whatever the firewall says.
- The app has no login, so it protects itself from web pages open in the same browser: it only answers requests addressed to `localhost` (against DNS rebinding), and refuses form posts that don't come from its own pages: each form carries a random token that another site can't know, and the browser's `Origin` must be the app's own.
- The local edition has no login, so it protects itself from web pages open in the same browser: it only answers requests addressed to `localhost` (against DNS rebinding), and refuses form posts that don't come from its own pages: each form carries a random token that another site can't know, and the browser's `Origin` must be the app's own.
- The container runs as you, with a read-only filesystem, no Linux capabilities and `no-new-privileges`. It can write only its data folder.
- `/mcp` requires the bearer token in `mcp-token`.
## The server edition
Supermarket also runs on a server, for a team that signs in: one company,
at its own domain, with Postgres for its database and Caddy for HTTPS.
**Installing.** On a server with Docker and the compose plugin, clone this
repository and run `./install-server.sh`. It asks for:
- the domain people will open, pointed at the server
- how the certificate is made: from Let's Encrypt (the server must be
reachable from the internet on ports 80 and 443), from Caddy's own
certificate authority (a private network or VPN), or from your own CA
(`cert.pem` and `key.pem` in `server/certs/`)
- the mail server for invitations and password resets
(`smtp://user:password@host:587`, STARTTLS, or `smtps://…:465`)
It makes the database password and the secret key, writes them to
`server.env` (readable only by you), and starts Supermarket, Postgres, a
nightly backup and Caddy (`compose.server.yaml`). **Keep a copy of
`SUPERMARKET_SECRET_KEY`**: the keys and tokens in the database are encrypted
with it. Run `./install-server.sh` again after `git pull` to update.
**The first owner.** A new server prints a link to create its owner, once,
for a day (`install-server.sh` shows it; `supermarket setup-link` makes a new
one). The owner fills in the company's profile, then invites the others
under Settings → Users.
**People.** Admins can do everything; members get the modules they're given,
each to view or to edit, and see nothing else: their menu, the Overview,
Search and the SEO emails follow it, and the server refuses the rest. Each
person can turn on two-factor sign-in (an authenticator app) under Settings →
Your account, see where they're signed in, and connect their own social
accounts to post as. Sign-ins are limited per address and per IP, and an
account locks after 10 failures in a row (a password reset or an admin
unlocks it). Settings → Activity shows who did what.
**Social accounts and Search Console.** Each service's developer app needs the
server's addresses as its redirect URLs: `https://<domain>/auth/x/callback`,
`…/auth/linkedin/callback`, `…/auth/linkedin-page/callback`,
`…/auth/reddit/callback` and `…/auth/google/callback`.
**Backups.** Postgres is dumped every night at 03:00, and two weeks of dumps
are kept, in the `pgbackups` volume; Settings → Backups lists them and says
how to restore one, which is done on the server.
**A private network.** With Caddy's CA or your own, nothing on the internet
needs to reach the server; browsers need to trust the CA. Services that call
in (none yet) wouldn't reach it, so Supermarket polls instead, as on a
computer.
Hermes and the CRM bridge use the local edition's socket; on a server, agents
come with their own keys (Phase 11 in PLAN.md).
## Development
Requires Go (see `go.mod`).