-
Notifications
You must be signed in to change notification settings - Fork 2
Run in Production
This page gets a single ggscale instance running for real traffic. It covers two
paths that share the same server: Docker Compose with your own secrets and TLS in
front, or the ggscale-server binary against a remote Postgres. Pick one.
Backup, upgrade, and monitoring get their own pages later. This page is the minimum to serve players safely.
- Postgres. One database. The server applies its migrations on startup, so you point it at an empty database and it builds the schema.
-
A place to run one Go binary. The server listens on plain HTTP (default
:8080). Put TLS in front of it (see below). -
Secrets. Outside production the server generates signing keys into a
server_secretstable on first boot, so local runs need no secret config. In production you set the important ones yourself, because a generated key that lives only in one database is hard to rotate and share.
Set ENV=production. The server then refuses to boot unless the hardening
config is present, so a misconfiguration is caught at startup, before the server
takes traffic. The required set is:
-
DATABASE_URLand a separateDB_MIGRATE_URL(the migrate URL runs DDL and must differ from the app login). -
APP_REGIONset to an explicit region name, notlocal. -
JWT_SIGNING_KEYandEMAIL_VERIFY_SIGNING_KEY. -
CORS_ALLOWED_ORIGINSlisting your real origins, with no*. -
CONTROL_PANEL_BASE_URLonhttps://,CONTROL_PANEL_COOKIE_SECURE=true, andCONTROL_PANEL_BOOTSTRAP_TOKEN_FILE. -
METRICS_AUTH_TOKEN, orMETRICS_AUTH_DISABLED=trueto serve/metricsopen on purpose.
Generate each secret with a strong random value:
openssl rand -hex 32The full list of variables and defaults is in Configuration Reference.
Run the published image buildwrangler/ggscale:latest behind a TLS-terminating
reverse proxy.
- Write a Compose file with the server, your Postgres (or point at a managed one), and your secrets. Keep secrets out of the image; pass them as environment or mount them with the
<NAME>_FILEconvention. - Put a reverse proxy in front (Caddy, nginx, or a cloud load balancer) that terminates TLS and forwards to the server on
:8080. If the proxy sets a forwarded-IP header, allow it withTRUSTED_PROXY_HEADERandTRUSTED_PROXY_CIDRSso rate limits see the real client IP. - Start the stack. The server runs its migrations, then serves traffic.
Run ggscale-server directly on a host, pointed at a managed Postgres.
- Provide the same production environment as above. Point
DATABASE_URLat the app login role andDB_MIGRATE_URLat a role that can run DDL. - Set
MIGRATIONS_DIRto the migrations directory shipped with the binary. The container image already sets/migrations; a bare binary needs the path to its copy. - Start the binary under a process manager (systemd or similar). Front it with a TLS-terminating proxy, the same as Path A.
The server writes a one-time bootstrap token on first boot. In production point
CONTROL_PANEL_BOOTSTRAP_TOKEN_FILE at a file path, read the token from there,
and complete setup at https://<your-host>/v1/control-panel/setup. See
Onboarding a New Game for the walkthrough.
Local stacks catch mail in Mailpit. For real signup and invite email, set
SMTP_ADDR, SMTP_USER, SMTP_PASSWORD, SMTP_TLS, and MAIL_FROM to your
SMTP relay. See Configuration Reference.
Backup, upgrade, and monitoring pages come later. Until then, back up Postgres on your own schedule; it holds the whole system, including the generated secrets.