Docker Deployment
Self-host Open Sunsama with Docker Compose: one command builds the API and web app, starts PostgreSQL and creates the database tables.
One command builds Open Sunsama from source, starts PostgreSQL, and creates the database tables. You get the web app, the REST API, and the MCP connector for AI agents, all on your own machine or server.
Prerequisites
- Docker 20.10+ with Docker Compose 2.24+ (check with
docker compose version) - 2 GB of RAM or more (building the web app needs it)
- For a server: a domain name and a reverse proxy for HTTPS
Quick Start
git clone https://github.com/kaijiabo/open-sunsama.git
cd open-sunsama
docker compose up -d --build
The first build takes a few minutes. Then open http://localhost:3000 and create your account. To check the API, run curl http://localhost:3001/health.
This starts four containers:
- postgres: PostgreSQL 16. Its port is published on
127.0.0.1:5431only, so it is never reachable from the internet. - api: the API on port 3001. On every start it applies any new database migrations. On the first start it also generates
JWT_SECRETandCALENDAR_ENCRYPTION_KEYand stores them in theapi_secretsvolume, so logins survive restarts. - redis: Redis, which relays live updates between the API and open browser tabs. Also bound to localhost.
- web: the web app on port 3000.
docker compose up -d postgres starts only PostgreSQL, on localhost:5431. That is the setup for running from source.
Run on a Server
1. Set your public URLs
Create a .env file in the repository root:
API_URL=https://api.tasks.your-domain.com
WEB_APP_URL=https://tasks.your-domain.com
POSTGRES_PASSWORD=a-long-random-password
The web app has API_URL built into its JavaScript, and the API uses WEB_APP_URL for CORS. Both must match the exact addresses people type in the browser, including https://.
POSTGRES_PASSWORD only takes effect when the database volume is first created. Set it before your first start.
2. Start the stack
docker compose up -d --build
3. Put HTTPS in front
Point WEB_APP_URL at port 3000 and API_URL at port 3001. The API also serves a WebSocket at /ws, so the proxy must pass the Upgrade header. With Nginx:
# API
server {
listen 443 ssl http2;
server_name api.tasks.your-domain.com;
ssl_certificate /etc/letsencrypt/live/tasks.your-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/tasks.your-domain.com/privkey.pem;
location / {
proxy_pass http://localhost:3001;
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 $scheme;
}
# WebSocket support
location /ws {
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
# Web App
server {
listen 443 ssl http2;
server_name tasks.your-domain.com;
ssl_certificate /etc/letsencrypt/live/tasks.your-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/tasks.your-domain.com/privkey.pem;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Ports 3000 and 3001 are published on all interfaces. On a public server, let your firewall allow only 80 and 443.
Configuration
Docker Compose reads .env from the repository root. After you change it, run docker compose up -d --build again. The rebuild matters only for API_URL, since the web app bakes it in.
Core settings
| Variable | Default | Description |
|---|---|---|
API_URL |
http://localhost:3001 |
Public API URL. The web app calls it, and it is the OAuth issuer for MCP connectors, so your connector URL is ${API_URL}/mcp |
WEB_APP_URL |
http://localhost:3000 |
Public web app URL. Used for CORS, email links, and the MCP consent screen |
POSTGRES_PASSWORD |
opensunsama |
Database password, read when the volume is first created |
JWT_SECRET |
generated | Signs login tokens. Set your own with openssl rand -base64 32 |
CALENDAR_ENCRYPTION_KEY |
generated | Encrypts stored calendar credentials. Set your own with openssl rand -hex 32 |
ROLLOVER_ENABLED |
true |
Moves unfinished tasks to the next day at midnight |
If you set JWT_SECRET or CALENDAR_ENCRYPTION_KEY yourself, the generated values are ignored. Changing JWT_SECRET signs everyone out. Changing CALENDAR_ENCRYPTION_KEY means reconnecting calendars.
Features that need your own keys
Tasks, time blocks, focus mode, rollover, the REST API and the MCP connector work without any keys. These features call outside services:
| Feature | Variables |
|---|---|
| Google Calendar sync | GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET. The redirect URI is ${API_URL}/calendar/oauth/google/callback |
| Instant Google Calendar updates | WEBHOOK_BASE_URL (defaults to API_URL). Google sends change notifications to ${WEBHOOK_BASE_URL}/webhooks/google/calendar. Without a public https:// URL, the server polls Google every 5 minutes instead |
| Outlook Calendar sync | MICROSOFT_CLIENT_ID, MICROSOFT_CLIENT_SECRET. The redirect URI is ${API_URL}/calendar/oauth/outlook/callback |
| Email (reminders and summaries) | RESEND_API_KEY, FROM_EMAIL |
| File uploads | AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_S3_BUCKET_NAME, AWS_ENDPOINT_URL, AWS_DEFAULT_REGION (any S3-compatible storage) |
| Push notifications | VAPID_PUBLIC_KEY, VAPID_PRIVATE_KEY, VAPID_SUBJECT (generate with npx web-push generate-vapid-keys) |
Desktop and Mobile Apps
The desktop and mobile apps on the download page connect only to https://api.opensunsama.com. Their API address is fixed when they are built, so they can't sign in to your server. Use the web app in your browser instead.
To run the desktop app against your server, build it yourself: set VITE_API_URL (and VITE_WS_URL, for example wss://api.tasks.your-domain.com) when you build apps/desktop, and add your API's https:// and wss:// URLs to the http:default allow list in apps/desktop/src-tauri/capabilities/default.json.
AI agents work with your server too. Add ${API_URL}/mcp as a connector. Claude and ChatGPT need it served over public HTTPS.
Updating
git pull
docker compose up -d --build
The API applies new migrations when it starts. To run them on their own:
docker compose run --rm api node dist/migrate.js
Database Backup
Manual Backup
docker compose exec postgres pg_dump -U opensunsama opensunsama > backup.sql
Automated Backup Script
#!/bin/bash
cd /path/to/open-sunsama
BACKUP_DIR=/var/backups/opensunsama
DATE=$(date +%Y%m%d_%H%M%S)
docker compose exec -T postgres pg_dump -U opensunsama opensunsama | gzip > $BACKUP_DIR/backup_$DATE.sql.gz
# Keep last 7 days
find $BACKUP_DIR -name "backup_*.sql.gz" -mtime +7 -delete
Add to crontab:
0 2 * * * /path/to/backup.sh
Restore
gunzip < backup.sql.gz | docker compose exec -T postgres psql -U opensunsama opensunsama
Monitoring
View Logs
# All services
docker compose logs -f
# Specific service
docker compose logs -f api
Health Check
curl http://localhost:3001/health
A healthy API answers with "status": "ok" and "pgBossRunning": true under jobs. PG Boss runs rollover, reminders and calendar sync.
Troubleshooting
The API keeps restarting
Run docker compose logs api. A line starting with [Migrations] Failed means the database schema couldn't be updated. The error below it names the table or column.
CORS errors in the browser
WEB_APP_URL must equal the address in your browser's address bar, including https:// and any port. Fix .env, then run docker compose up -d.
The web app calls localhost:3001 on your server
The web app was built before you set API_URL. Rebuild it with docker compose up -d --build.
Port 5431, 6379, 3000 or 3001 is already in use
Stop whatever uses the port, or change the host side of the mapping in docker-compose.yml, for example "127.0.0.1:5433:5432".
Next Steps
- API Reference - REST API documentation
- MCP Setup - Connect AI agents