services:
  postgres:
    image: postgres:15-alpine
    container_name: mixvideo_postgres
    restart: unless-stopped
    environment:
      POSTGRES_DB: mixvideo
      POSTGRES_USER: mixvideo_user
      POSTGRES_PASSWORD: mixvideo_password
      POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C"
    ports:
      - "5433:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./init-scripts:/docker-entrypoint-initdb.d
    networks:
      - mixvideo_network
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U mixvideo_user -d mixvideo"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 30s

  # 可选：PostgreSQL 管理界面 (pgAdmin)
  pgadmin:
    image: dpage/pgadmin4:latest
    container_name: mixvideo_pgadmin
    restart: unless-stopped
    environment:
      PGADMIN_DEFAULT_EMAIL: admin@mixvideo.com
      PGADMIN_DEFAULT_PASSWORD: admin123
      PGADMIN_CONFIG_SERVER_MODE: 'False'
    ports:
      - "8080:80"
    volumes:
      - pgadmin_data:/var/lib/pgadmin
    networks:
      - mixvideo_network
    depends_on:
      postgres:
        condition: service_healthy

volumes:
  postgres_data:
    driver: local
  pgadmin_data:
    driver: local

networks:
  mixvideo_network:
    driver: bridge
