Benchrun

2026-11-16 · finance · docker · rails · self-hosting

Self-Host Sure Personal Finance with Docker Compose

Run Sure, the open-source personal finance app, with Docker Compose: Rails web, Sidekiq worker, Postgres 16, Redis, HTTPS reverse proxy, and backups.

Bench run · 2026-11-16 Verified
we-promise/sure
Total RAM
798.3 MB
Startup
77.6 s
Port
3000
HTTP
302
Per container web 381.1 MB · worker 367.7 MB · db 39.0 MB · redis 10.5 MB
postgres:16 · 4 containers · we-promise/sure

What Sure does and what it needs

Sure is a community-maintained fork of the abandoned Maybe Finance codebase. It’s a full personal finance app: accounts, transactions, budgets, net worth tracking, investment holdings, AI-assisted categorization, and a chat assistant. You can reach it from a browser, the macOS desktop app, mobile clients, and API/LLM agents.

The stack is a standard Rails deployment:

  • web — the Rails app served by Puma on port 3000 inside the container.
  • worker — Sidekiq, which runs scheduled jobs (market data sync, rule notifications, PDF import follow-ups) and sends email.
  • db — PostgreSQL 16, holding all financial data.
  • redis — Sidekiq’s queue backend (database 1 by default).
  • app-storage — a named volume mounted at /rails/storage for Active Storage uploads (imported PDFs, attachments).

The upstream project does not publish a minimum RAM figure. Plan around workload: an idle instance with a few accounts is light, but PDF imports, market data syncs, and AI chat turns are the memory-heavy paths. If you enable OpenAI-backed features, budget for the outbound API calls too.

Prerequisites, ports, and volume constraints

  • Docker Engine and the Compose plugin on a Linux host.
  • A domain name if you want HTTPS. The app itself speaks plain HTTP; TLS terminates at your reverse proxy.
  • Port 3000 is the app’s internal port. In this guide we bind it to 127.0.0.1:3000 so only the reverse proxy on the same host can reach it.
  • Two named volumes matter: postgres-data (the database) and app-storage (uploads). Back both up.
  • SECRET_KEY_BASE is mandatory and has no default. It also seeds Active Record encryption keys when ACTIVE_RECORD_ENCRYPTION_* are unset, so a guessable value lets anyone forge session cookies and derive your encryption keys. Generate it with openssl rand -hex 64.
  • If you’re upgrading an existing install, keep the existing SECRET_KEY_BASE. Generating a new one makes already-encrypted data unreadable.

Production Docker Compose setup

Create the project directory and write the compose file. This mirrors the official compose.example.yml but binds the web port to localhost and wires the production variables through .env.

mkdir -p ~/docker-apps/sure
cd ~/docker-apps/sure

cat <<'EOF' > compose.yml
x-db-env: &db_env
  POSTGRES_USER: ${POSTGRES_USER:-sure_user}
  POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
  POSTGRES_DB: ${POSTGRES_DB:-sure_production}

x-rails-env: &rails_env
  <<: *db_env
  SECRET_KEY_BASE: ${SECRET_KEY_BASE}
  ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY: ${ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY:-}
  ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY: ${ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY:-}
  ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT: ${ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT:-}
  SELF_HOSTED: "true"
  ONBOARDING_STATE: ${ONBOARDING_STATE:-open}
  RAILS_FORCE_SSL: "false"
  RAILS_ASSUME_SSL: "true"
  APP_DOMAIN: ${APP_DOMAIN}
  DB_HOST: db
  DB_PORT: 5432
  REDIS_URL: redis://redis:6379/1
  SIDEKIQ_CRON_GRACE_PERIOD_SECONDS: ${SIDEKIQ_CRON_GRACE_PERIOD_SECONDS:-}
  OPENAI_ACCESS_TOKEN: ${OPENAI_ACCESS_TOKEN:-}
  OPENAI_MODEL: ${OPENAI_MODEL:-}
  OPENAI_URI_BASE: ${OPENAI_URI_BASE:-}
  OPENAI_REQUEST_TIMEOUT: ${OPENAI_REQUEST_TIMEOUT:-60}
  AI_RESPONSE_TIMEOUT: ${AI_RESPONSE_TIMEOUT:-90}
  ASSISTANT_MAX_TOOL_CALL_ITERATIONS: ${ASSISTANT_MAX_TOOL_CALL_ITERATIONS:-}
  SMTP_ADDRESS: ${SMTP_ADDRESS:-}
  SMTP_PORT: ${SMTP_PORT:-465}
  SMTP_USERNAME: ${SMTP_USERNAME:-}
  SMTP_PASSWORD: ${SMTP_PASSWORD:-}
  SMTP_TLS_ENABLED: ${SMTP_TLS_ENABLED:-true}
  SMTP_TLS_SKIP_VERIFY: ${SMTP_TLS_SKIP_VERIFY:-false}
  EMAIL_SENDER: ${EMAIL_SENDER:-}
  EXCHANGE_RATE_PROVIDER: ${EXCHANGE_RATE_PROVIDER:-yahoo_finance}
  SECURITIES_PROVIDER: ${SECURITIES_PROVIDER:-yahoo_finance}

services:
  web:
    image: ghcr.io/we-promise/sure:${SURE_IMAGE_TAG:-stable}
    volumes:
      - app-storage:/rails/storage
    ports:
      - 127.0.0.1:${PORT:-3000}:3000
    restart: unless-stopped
    environment:
      <<: *rails_env
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_healthy
    dns:
      - 8.8.8.8
      - 1.1.1.1
    networks:
      - sure_net

  worker:
    image: ghcr.io/we-promise/sure:${SURE_IMAGE_TAG:-stable}
    command: bundle exec sidekiq
    volumes:
      - app-storage:/rails/storage
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_healthy
    dns:
      - 8.8.8.8
      - 1.1.1.1
    environment:
      <<: *rails_env
    networks:
      - sure_net

  db:
    image: postgres:16
    restart: unless-stopped
    volumes:
      - postgres-data:/var/lib/postgresql/data
    environment:
      <<: *db_env
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
      interval: 5s
      timeout: 5s
      retries: 5
    networks:
      - sure_net

  redis:
    image: redis:7-alpine
    restart: unless-stopped
    volumes:
      - redis-data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 5s
      retries: 5
    networks:
      - sure_net

volumes:
  app-storage:
  postgres-data:
  redis-data:

networks:
  sure_net:
    driver: bridge
EOF

Now write .env. Generate the secrets first:

openssl rand -hex 64   # SECRET_KEY_BASE
openssl rand -hex 32   # POSTGRES_PASSWORD
cat <<'EOF' > .env
SECRET_KEY_BASE=<paste the 128-char hex string>
POSTGRES_USER=sure_user
POSTGRES_PASSWORD=<paste the 64-char hex string>
POSTGRES_DB=sure_production
PORT=3000
APP_DOMAIN=sure.example.com
ONBOARDING_STATE=open
SURE_IMAGE_TAG=stable

# Optional: SMTP for password resets and rule notifications
SMTP_ADDRESS=
SMTP_PORT=465
SMTP_USERNAME=
SMTP_PASSWORD=
SMTP_TLS_ENABLED=true
EMAIL_SENDER=sure@example.com

# Optional: AI features (OpenAI-compatible endpoint)
OPENAI_ACCESS_TOKEN=
OPENAI_MODEL=
OPENAI_URI_BASE=
EOF
chmod 600 .env

Start the stack:

docker compose up -d
docker compose logs -f web

The first boot runs database migrations. Wait until the logs settle, then open http://127.0.0.1:3000 from the host (or via an SSH tunnel: ssh -L 3000:127.0.0.1:3000 user@vps).

Reverse proxy, HTTPS, and first-run hardening

Sure runs plain HTTP inside the container. Your proxy terminates TLS and forwards to 127.0.0.1:3000. Because RAILS_ASSUME_SSL is set to true, the app builds HTTPS URLs and sets secure cookies correctly.

Caddy example (/etc/caddy/Caddyfile):

sure.example.com {
    encode gzip
    reverse_proxy 127.0.0.1:3000 {
        header_up X-Forwarded-Proto https
        header_up X-Forwarded-For {remote_host}
    }
    request_body {
        max_size 100MB
    }
}

Nginx equivalent:

server {
    listen 443 ssl http2;
    server_name sure.example.com;
    client_max_body_size 100M;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_read_timeout 300s;
    }
}

Notes specific to Sure:

  • Upload size. PDF imports and attachments go through the web app. Set client_max_body_size (Nginx) or request_body max_size (Caddy) to at least 100 MB, or imports fail with a 413.
  • Long requests. AI chat turns can take up to AI_RESPONSE_TIMEOUT seconds (default 90). Raise proxy_read_timeout accordingly if you use the assistant.
  • First-run signup. With ONBOARDING_STATE=open, the first visitor can create an account. Register your admin account immediately after the stack is healthy, then set ONBOARDING_STATE=closed in .env and run docker compose up -d to restart with the new value. Leaving it open on a public domain lets strangers register.
  • Email confirmation. If you enable “Require email confirmation” under Settings > Self-Hosting, SMTP must be configured on the worker service — that’s where mail is sent from. Invitations are never emailed on self-hosted instances; copy the invite link from Settings > Profile Info and send it yourself.
  • WebAuthn/passkeys. If you enable passkey login, set WEBAUTHN_RP_ID to your bare domain (e.g. sure.example.com) and WEBAUTHN_ALLOWED_ORIGINS to the full origin (e.g. https://sure.example.com).

Updating, backups, and common pitfalls

Update:

cd ~/docker-apps/sure
docker compose pull
docker compose up -d
docker compose logs -f web

Migrations run on boot. Pin SURE_IMAGE_TAG to a specific release if you want to control when upgrades land.

Backups. The official compose file ships a backup service that captures the database, app-storage, .env, and compose.yml into ./backups/<version>/<timestamp>-<trigger>/. Add it to your compose file from the upstream example, then:

docker compose --profile backup run --rm backup create
docker compose --profile backup up -d backup   # daily at 02:00 by default

If you prefer manual backups, dump the two volumes that matter:

docker compose exec -T db pg_dump -U sure_user sure_production | gzip > sure-db-$(date +%F).sql.gz
docker run --rm -v sure_app-storage:/data -v "$PWD":/backup alpine tar czf /backup/sure-storage-$(date +%F).tar.gz -C /data .

Restore by piping the dump back into psql and untarring into app-storage while the stack is stopped.

Pitfalls from the docs:

  1. Yahoo Finance IPv6 hangs. If market data sync fails with Failed to open TCP connection to fc.yahoo.com, DNS is resolving to IPv6 inside the container and the connection hangs. The compose file already sets dns: [8.8.8.8, 1.1.1.1]; if that isn’t enough, add extra_hosts entries pinning the IPv4 addresses, or switch EXCHANGE_RATE_PROVIDER/SECURITIES_PROVIDER to a provider with an API key (e.g. Twelve Data).
  2. Rotating SECRET_KEY_BASE breaks encrypted data. Provider API tokens and other sensitive fields are encrypted with keys derived from SECRET_KEY_BASE when ACTIVE_RECORD_ENCRYPTION_* are unset. If you set the three ACTIVE_RECORD_ENCRYPTION_* variables explicitly, set all three or none — adding them to an instance that already has data changes its keys and makes existing encrypted fields unreadable. Back up .env alongside the database so you can restore the exact key set.

Measured in our sandbox run: total memory 798.3 MB (sum of per-container peaks over a 30s idle window after startup) across 4 containers; largest container 381.1 MB; published port(s) 3000; HTTP probe returned 302. The run took 77.6s including the image download. Required secret(s) APP_DOMAIN, POSTGRES_PASSWORD, SECRET_KEY_BASE were generated for the test run, as the tutorial instructs. Container breakdown: web 381.1 MB, worker 367.7 MB, db 39.0 MB, redis 10.5 MB.


Verification: we ran this docker-compose stack in a disposable Docker environment and recorded the measurements above. They describe that run, not a guarantee for your host.