Docker Deployment
Overview
Section titled “Overview”Chatty the Lab provides two Docker Compose files:
docker-compose.yml— Development setup (Supabase runs separately via CLI)docker-compose.prod.yml— Production setup (includes Supabase services)
Development setup
Section titled “Development setup”The development compose file assumes Supabase is running via supabase start on the host.
Services
Section titled “Services”| Service | Image | Port | Description |
|---|---|---|---|
ollama | ollama/ollama:latest | 11434 | Local LLM inference and embeddings |
backend | Built from ./backend | 5000 | Rust Axum API server |
frontend | Built from ./frontend | 3000 | SvelteKit application |
Running
Section titled “Running”# Start Supabase first (if not already running)supabase start
# Start Docker servicesdocker compose up -dEnvironment variables
Section titled “Environment variables”Create a .env file in the project root:
SUPABASE_JWT_SECRET=your-jwt-secretPUBLIC_SUPABASE_URL=http://localhost:54321PUBLIC_SUPABASE_ANON_KEY=your-anon-keyOPENAI_KEY=sk-... # optionalMISTRAL_KEY=... # optionalGEMINI_KEY=... # optionalThe compose file uses defaults for most variables. The backend connects to the host’s Supabase via host.docker.internal:54322.
Production setup
Section titled “Production setup”The production compose file includes Supabase services and GPU support for Ollama.
Services
Section titled “Services”| Service | Image | Port | Description |
|---|---|---|---|
supabase-db | supabase/postgres:15.6.1.143 | 54322 | PostgreSQL with pgvector |
supabase-auth | supabase/gotrue:v2.164.0 | 54321 | Authentication service |
ollama | ollama/ollama:latest | 11434 | LLM inference (with GPU) |
backend | Built from ./backend | 5000 | Rust Axum API server |
frontend | Built from ./frontend | 3000 | SvelteKit application |
Running
Section titled “Running”docker compose -f docker-compose.prod.yml up -dEnvironment variables for production
Section titled “Environment variables for production”# RequiredSUPABASE_JWT_SECRET=a-strong-random-secretPOSTGRES_PASSWORD=a-strong-database-passwordPUBLIC_SUPABASE_ANON_KEY=your-anon-keyGOOGLE_CLIENT_ID=your-google-client-idGOOGLE_CLIENT_SECRET=your-google-client-secret
# URLsSITE_URL=https://tec.citius.usc.es/chattySUPABASE_URL=http://supabase-auth:9999
# API keys (optional)OPENAI_KEY=sk-...MISTRAL_KEY=...GEMINI_KEY=...GPU support for Ollama
Section titled “GPU support for Ollama”The production compose file includes NVIDIA GPU reservation for Ollama:
ollama: deploy: resources: reservations: devices: - driver: nvidia count: all capabilities: [gpu]Volumes
Section titled “Volumes”| Volume | Service | Purpose |
|---|---|---|
ollama-data | ollama | Persists downloaded models between restarts |
supabase-db-data | supabase-db | Persists PostgreSQL data (production only) |
Health checks
Section titled “Health checks”The compose files include health checks for critical services:
- Ollama:
curl -f http://localhost:11434/every 30s - Supabase DB:
pg_isready -U postgresevery 10s
The backend and frontend services use depends_on with condition: service_healthy to ensure dependencies are ready before starting.
Dockerfiles
Section titled “Dockerfiles”Backend (multi-stage Rust build)
Section titled “Backend (multi-stage Rust build)”FROM rust:1.82-slim AS builder# Install dependencies, build release binary
FROM debian:bookworm-slim# Copy binary, expose port 5000Frontend (multi-stage Node build)
Section titled “Frontend (multi-stage Node build)”FROM node:22-slim AS builder# npm ci && npm run build
FROM node:22-slim# Copy build output, expose port 3000To rebuild after code changes:
docker compose builddocker compose up -dApplying database migrations
Section titled “Applying database migrations”When using the production compose file with supabase-db, you need to apply migrations manually:
# Copy migrations into the container and applyfor f in supabase/migrations/*.sql; do docker compose -f docker-compose.prod.yml exec -T supabase-db \ psql -U postgres -d postgres < "$f"doneAlternatively, mount the migrations directory as a volume and apply them on startup.