version: '3.8'

services:
  web_sentinel_mysql:
    image: mysql:8.0
    container_name: web_sentinel_db
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: web_sentinel_root_secure_2024
      MYSQL_DATABASE: web_sentinel_db
      MYSQL_USER: web_sentinel_user
      MYSQL_PASSWORD: web_sentinel_secure_password_2024
      TZ: UTC
    ports:
      - "3307:3306"  # Port externe 3307 pour éviter conflits avec autres MySQL
    volumes:
      - web_sentinel_mysql_data:/var/lib/mysql
      - web_sentinel_mysql_logs:/var/log/mysql
      - ./docker/mysql/conf/my.cnf:/etc/mysql/conf.d/web_sentinel.cnf:ro
      - ./docker/mysql/init:/docker-entrypoint-initdb.d:ro
    networks:
      - web_sentinel_network
    command: --default-authentication-plugin=mysql_native_password
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "web_sentinel_user", "-pweb_sentinel_secure_password_2024"]
      timeout: 20s
      retries: 10
      interval: 30s
      start_period: 40s
    labels:
      - "com.websentinel.component=database"
      - "com.websentinel.environment=development"
      - "com.websentinel.version=1.0.0"

volumes:
  web_sentinel_mysql_data:
    name: web_sentinel_mysql_data
    driver: local
  web_sentinel_mysql_logs:
    name: web_sentinel_mysql_logs
    driver: local

networks:
  web_sentinel_network:
    name: web_sentinel_network
    driver: bridge
    ipam:
      config:
        - subnet: 172.20.0.0/16