# Aether 部署配置 - 使用预构建镜像
# 使用方法: docker-compose up -d

services:
  postgres:
    image: postgres:15
    container_name: aether-postgres
    environment:
      POSTGRES_DB: aether
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      TZ: Asia/Shanghai
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "${DB_PORT:-5432}:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  redis:
    image: redis:7-alpine
    container_name: aether-redis
    command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD}
    volumes:
      - redis_data:/data
    ports:
      - "${REDIS_PORT:-6379}:6379"
    healthcheck:
      test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
      interval: 5s
      timeout: 3s
      retries: 5
    restart: unless-stopped

  app:
    image: ghcr.io/fawney19/aether:latest
    container_name: aether-app
    environment:
      DATABASE_URL: postgresql://postgres:${DB_PASSWORD}@postgres:5432/aether
      REDIS_URL: redis://:${REDIS_PASSWORD}@redis:6379/0
      PORT: 8084
      JWT_SECRET_KEY: ${JWT_SECRET_KEY}
      ENCRYPTION_KEY: ${ENCRYPTION_KEY}
      JWT_ALGORITHM: HS256
      JWT_EXPIRATION_DELTA: 86400
      LOG_LEVEL: ${LOG_LEVEL:-INFO}
      ADMIN_EMAIL: ${ADMIN_EMAIL}
      ADMIN_USERNAME: ${ADMIN_USERNAME}
      ADMIN_PASSWORD: ${ADMIN_PASSWORD}
      API_KEY_PREFIX: ${API_KEY_PREFIX:-sk}
      GUNICORN_WORKERS: ${GUNICORN_WORKERS:-4}
      TZ: Asia/Shanghai
      PYTHONIOENCODING: utf-8
      LANG: C.UTF-8
      LC_ALL: C.UTF-8
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
    ports:
      - "${APP_PORT:-8084}:80"
    volumes:
      - ./logs:/app/logs
    restart: unless-stopped

volumes:
  postgres_data:
  redis_data:
