solventum-image-metadata/docker-compose.fastapi.yml
SamoilenkoVadym a95f7be047 feat(deploy): add production deployment for Ubuntu with Docker
- Create idempotent deploy.sh for production deployment
- Add docker-compose.fastapi.yml with Redis + Backend
- Configure health checks for all services
- Add .env.fastapi.example with all configuration
- Remove old Flask deployment script (docker-run.sh)

Deployment features:
- Pre-flight checks (Docker, Node, permissions)
- Frontend build with Vite
- Deploy to /var/www/html/solventum-image-metadata
- Graceful container restart
- Health checks (backend + Redis)
- Auto-cleanup old Docker images

Usage:
  cd /opt/solventum-image-metadata
  git pull origin main
  sudo ./deploy.sh

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2026-02-09 13:15:04 +00:00

123 lines
3.1 KiB
YAML

version: '3.9'
services:
# Redis for session storage
redis:
image: redis:7-alpine
container_name: oliver-redis
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- redis-data:/data
command: redis-server --appendonly yes
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 3
networks:
- oliver-network
# PostgreSQL database (optional - can use SQLite)
postgres:
image: postgres:15-alpine
container_name: oliver-postgres
restart: unless-stopped
environment:
POSTGRES_DB: oliver_metadata
POSTGRES_USER: oliver
POSTGRES_PASSWORD: ${DB_PASSWORD:-changeme}
volumes:
- postgres-data:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U oliver"]
interval: 10s
timeout: 3s
retries: 3
networks:
- oliver-network
# FastAPI Backend
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: oliver-backend
restart: unless-stopped
environment:
# Database - use SQLite by default (simpler for migration)
DATABASE_URL: sqlite+aiosqlite:///./data/oliver_metadata.db
# Or use PostgreSQL:
# DATABASE_URL: postgresql+asyncpg://oliver:${DB_PASSWORD:-changeme}@postgres:5432/oliver_metadata
# Redis
REDIS_URL: redis://redis:6379/0
# Security
SECRET_KEY: ${SECRET_KEY:-please-change-this-secret-key-in-production}
# OpenAI (for AI metadata generation)
OPENAI_API_KEY: ${OPENAI_API_KEY}
AI_MODEL: ${AI_MODEL:-gpt-4o-mini}
MAX_TOKENS: ${MAX_TOKENS:-500}
TEMPERATURE: ${TEMPERATURE:-0.5}
# Microsoft SSO (optional)
AZURE_CLIENT_ID: ${AZURE_CLIENT_ID}
AZURE_CLIENT_SECRET: ${AZURE_CLIENT_SECRET}
AZURE_TENANT_ID: ${AZURE_TENANT_ID}
REDIRECT_URI: ${REDIRECT_URI:-http://localhost:8000/auth/microsoft/callback}
# Debugging
DEBUG: ${DEBUG:-false}
# Upload directory
UPLOAD_DIR: /app/uploads
volumes:
# Persistent storage for uploads
- ./backend/uploads:/app/uploads
# Persistent database (SQLite)
- ./backend/data:/app/data
# Persistent templates
- ./backend/output:/app/output
# Copy existing Excel lookup file (if exists)
- type: bind
source: ./Celum ID to Adobe Asset Path Mapping Spreadsheet (1).xlsx
target: /app/Celum ID to Adobe Asset Path Mapping Spreadsheet (1).xlsx
read_only: true
# Optional - won't fail if file doesn't exist
bind:
create_host_path: false
ports:
- "8000:8000"
depends_on:
redis:
condition: service_healthy
networks:
- oliver-network
command: uvicorn app.main:app --host 0.0.0.0 --port 8000
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
volumes:
redis-data:
driver: local
postgres-data:
driver: local
networks:
oliver-network:
driver: bridge