Docker Deployment¶
Deploy Tessera with Docker and Docker Compose.
Quick Start¶
This starts: - Tessera API on port 8000 - PostgreSQL on port 5432
Docker Compose Configuration¶
Basic Setup¶
# docker-compose.yml
services:
api:
build: .
ports:
- "8000:8000"
environment:
- DATABASE_URL=postgresql+asyncpg://tessera:tessera@db:5432/tessera
- SESSION_SECRET_KEY=${SESSION_SECRET_KEY}
- BOOTSTRAP_API_KEY=${BOOTSTRAP_API_KEY}
depends_on:
db:
condition: service_healthy
db:
image: postgres:16-alpine
environment:
- POSTGRES_USER=tessera
- POSTGRES_PASSWORD=tessera
- POSTGRES_DB=tessera
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U tessera"]
interval: 5s
timeout: 5s
retries: 5
volumes:
postgres_data:
With Redis Caching¶
services:
api:
build: .
environment:
- DATABASE_URL=postgresql+asyncpg://tessera:tessera@db:5432/tessera
- REDIS_URL=redis://redis:6379/0
- SESSION_SECRET_KEY=${SESSION_SECRET_KEY}
depends_on:
- db
- redis
db:
image: postgres:16-alpine
environment:
- POSTGRES_USER=tessera
- POSTGRES_PASSWORD=tessera
- POSTGRES_DB=tessera
volumes:
- postgres_data:/var/lib/postgresql/data
redis:
image: redis:7-alpine
volumes:
- redis_data:/data
volumes:
postgres_data:
redis_data:
Production Setup¶
services:
api:
build:
context: .
dockerfile: Dockerfile.prod
deploy:
replicas: 3
resources:
limits:
cpus: '1'
memory: 512M
environment:
- DATABASE_URL=postgresql+asyncpg://${DB_USER}:${DB_PASS}@db:5432/tessera
- REDIS_URL=redis://redis:6379/0
- SESSION_SECRET_KEY=${SESSION_SECRET_KEY}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
Environment Variables¶
Create a .env file:
# Required
SESSION_SECRET_KEY=your-secret-key-at-least-32-characters
BOOTSTRAP_API_KEY=tsk_your_bootstrap_key
# Database
POSTGRES_USER=tessera
POSTGRES_PASSWORD=secure-password
POSTGRES_DB=tessera
# Optional
REDIS_URL=redis://redis:6379/0
SLACK_WEBHOOK_URL=https://hooks.slack.com/...
Building from Source¶
# Build the image
docker build -t tessera:local .
# Run with local build
docker compose -f docker-compose.yml up -d
Database Migrations¶
Migrations run automatically on startup. To run manually: