version: '3.8'

services:
  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    ports:
      - "4000:80"
    depends_on:
      - backend
    environment:
      - API_BASE_URL=http://localhost:9000/api
    volumes:
      - ./frontend/static:/usr/share/nginx/html/static
    restart: unless-stopped

  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    ports:
      - "9000:9000"
    depends_on:
      - database
    environment:
      - DATABASE_URL=postgresql+asyncpg://todo_user:${POSTGRES_PASSWORD:-todo_password}@database:5432/todo_db
      - SECRET_KEY=${SECRET_KEY:-your-secret-key-change-this-in-production}
      - DEBUG=${DEBUG:-true}
      - CORS_ORIGINS=["http://localhost:4000", "http://127.0.0.1:4000"]
      - SYNOLOGY_DSM_URL=${SYNOLOGY_DSM_URL:-}
      - SYNOLOGY_USERNAME=${SYNOLOGY_USERNAME:-}
      - SYNOLOGY_PASSWORD=${SYNOLOGY_PASSWORD:-}
      - ENABLE_SYNOLOGY_INTEGRATION=${ENABLE_SYNOLOGY_INTEGRATION:-false}
    volumes:
      - ./backend/src:/app/src
      - ./backend/uploads:/app/uploads
      - todo_uploads:/data/uploads
    restart: unless-stopped

  database:
    image: postgres:15-alpine
    ports:
      - "5434:5432"
    environment:
      - POSTGRES_USER=${POSTGRES_USER:-todo_user}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-todo_password}
      - POSTGRES_DB=${POSTGRES_DB:-todo_db}
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./database/init:/docker-entrypoint-initdb.d
    restart: unless-stopped

volumes:
  postgres_data:
  todo_uploads:
