Docker Self-Hosting#
Docker Compose is the primary recommended method for self-hosting Sure. Two compose templates are provided: a standard setup (compose.example.yml) and an AI-extended setup (compose.example.ai.yml). The official setup guide lives at docs/hosting/docker.md.
Services#
The standard compose file defines five services on a shared sure_net bridge network:
| Service | Image | Role |
|---|---|---|
web | ghcr.io/we-promise/sure:stable | Rails web server, port 3000 |
worker | ghcr.io/we-promise/sure:stable | Sidekiq background jobs |
db | postgres:16 | PostgreSQL database |
redis | redis:latest | Job queue / cache |
backup | prodrigestivill/postgres-backup-local | Scheduled DB backups (optional profile) |
webandworkershare the same image;workeroverridescommand: bundle exec sidekiq.- Both
webandworkermount theapp-storagevolume and depend ondbandredishealth checks . dbandrediseach have health checks and dedicated named volumes (postgres-data,redis-data) .- The
backupservice is opt-in via--profile backupand retains 7 daily, 4 weekly, and 6 monthly snapshots by default .
Both web and worker use Google and Cloudflare DNS (8.8.8.8, 1.1.1.1) to avoid IPv6-first resolution issues with external services like Yahoo Finance .
Key Environment Variables#
Shared Rails config is set via a YAML anchor &rails_env :
| Variable | Default | Purpose |
|---|---|---|
SECRET_KEY_BASE | (bundled default; change for prod) | Rails encryption secret |
POSTGRES_PASSWORD | sure_password | DB password |
POSTGRES_USER | sure_user | DB user |
POSTGRES_DB | sure_production | DB name |
REDIS_URL | redis://redis:6379/1 | Redis connection |
RAILS_ASSUME_SSL | false | Set to true when behind an HTTPS reverse proxy |
OPENAI_ACCESS_TOKEN | (unset) | Enables AI features (incurs OpenAI costs) |
SELF_HOSTED | true | Marks instance as self-hosted |
For hardened deployments, generate a custom SECRET_KEY_BASE with openssl rand -hex 64 and set POSTGRES_PASSWORD in a .env file .
Setup Quickstart#
Full instructions are in docs/hosting/docker.md. The abbreviated flow:
# 1. Download the compose file
curl -o compose.yml https://raw.githubusercontent.com/we-promise/sure/main/compose.example.yml
# 2. (Recommended) Create .env with SECRET_KEY_BASE and POSTGRES_PASSWORD
curl -o .env https://raw.githubusercontent.com/we-promise/sure/main/.env.example
# 3. Start
docker compose up -d
# App is available at http://localhost:3000
Updates: Pull the new image, rebuild, and restart only the app containers :
docker compose pull
docker compose build
docker compose up --no-deps -d web worker
Image tags available at ghcr.io/we-promise/sure: stable (latest release) and latest (latest alpha) .
Optional: HTTPS, IPv6, WebAuthn#
- HTTPS behind a reverse proxy: Set
RAILS_ASSUME_SSL: "true"incompose.yml. - IPv6 dual-stack: Add
"[::]:${PORT:-3000}:3000"towebports and setBINDING: "::"in its environment . - WebAuthn MFA (passkeys): Pin
WEBAUTHN_RP_IDandWEBAUTHN_ALLOWED_ORIGINSin.envbefore enabling passkeys . - Signup control: After first-account creation, configure open / invite-only / closed registration under Settings > Self-Hosting > Onboarding .
AI Compose Extension (compose.example.ai.yml)#
compose.example.ai.yml extends the standard setup with AI-focused services :
| Service | Profile | Role |
|---|---|---|
pipelock | (always on) | AI security proxy — DLP, prompt injection, tool-poisoning scanning |
ollama | local-ai / external-assistant | Local LLM inference |
ollama-webui | local-ai / external-assistant | Open WebUI frontend for Ollama |
openclaw | external-assistant | OpenClaw gateway for Sure's external AI assistant mode |
- In this compose file
dbusespgvector/pgvector:pg16instead of plainpostgres:16to support vector embeddings . - Pipelock runs on port 8888 (forward proxy for outbound HTTPS) and port 8889 (MCP reverse proxy for inbound AI agent traffic) . External AI clients should target port 8889 rather than Sure's
/mcpendpoint directly. - See docs/hosting/docker.md — AI features section for full AI setup instructions.
Troubleshooting#
ActiveRecord::DatabaseConnectionErroron first start: Postgres volume may be initialized with a different role. Reset withdocker compose down && docker volume rm sure_postgres-data.- Slow CSV import: Requires the worker to communicate with Redis; check worker logs for Redis timeouts .
- Yahoo Finance / IPv6 TCP errors: The
dnsoverride incompose.ymlto8.8.8.8/1.1.1.1mitigates most cases; alternatively addextra_hostsentries for specific Yahoo Finance IP addresses .