version: '3.8'

services:
  web:
    build: .
    container_name: sheerid_web
    restart: unless-stopped
    env_file:
      - .env
    ports:
      - "6969:5000"
    volumes:
      - ./logs:/app/logs
    depends_on:
      mysql:
        condition: service_healthy
    networks:
      - app-network
    environment:
      - FLASK_APP=app.py
      - PYTHONUNBUFFERED=1

  mysql:
    image: mysql:5.7
    container_name: sheerid_mysql
    restart: unless-stopped
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-authentication-plugin=mysql_native_password
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root_password}
      MYSQL_DATABASE: ${MYSQL_DATABASE:-sheerid_verify}
      MYSQL_USER: ${MYSQL_USER:-sheerid_user}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD:-your_password_here}
    volumes:
      - mysql-data:/var/lib/mysql
    ports:
      - "3306:3306"
    networks:
      - app-network
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-proot_password"]
      interval: 10s
      timeout: 5s
      retries: 10
      start_period: 30s

  # Optional: Nginx reverse proxy for production
  # Uncomment below to enable Nginx
  # nginx:
  #   image: nginx:alpine
  #   container_name: sheerid_nginx
  #   restart: unless-stopped
  #   ports:
  #     - "80:80"
  #     - "443:443"
  #   volumes:
  #     - ./nginx.conf:/etc/nginx/nginx.conf
  #     - ./ssl:/etc/nginx/ssl
  #   depends_on:
  #     - web
  #   networks:
  #     - app-network

networks:
  app-network:
    driver: bridge

volumes:
  mysql-data:
