version: '3.8'

services:
  web:
    build: .
    image: ${DOCKER_USER:-seuusuario}/alerta-rj:latest
    container_name: alerta-rj-web
    ports:
      - "8080:80"
    environment:
      - DB_HOST=mysql
      - DB_NAME=risco_rj
      - DB_USER=risco_user
      - DB_PASS=risco_pass_123
      - FOGO_CRUZADO_EMAIL=${FOGO_CRUZADO_EMAIL}
      - FOGO_CRUZADO_PASSWORD=${FOGO_CRUZADO_PASSWORD}
    depends_on:
      mysql:
        condition: service_healthy
    networks:
      - alerta-network
    restart: unless-stopped

  mysql:
    image: mysql:8.0
    container_name: alerta-rj-mysql
    environment:
      MYSQL_ROOT_PASSWORD: root_pass_123
      MYSQL_DATABASE: risco_rj
      MYSQL_USER: risco_user
      MYSQL_PASSWORD: risco_pass_123
    volumes:
      - mysql_data:/var/lib/mysql
      - ./database/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql
    ports:
      - "3306:3306"
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-proot_pass_123"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - alerta-network
    restart: unless-stopped

  phpmyadmin:
    image: phpmyadmin:latest
    container_name: alerta-rj-phpmyadmin
    environment:
      PMA_HOST: mysql
      PMA_USER: risco_user
      PMA_PASSWORD: risco_pass_123
    ports:
      - "8081:80"
    depends_on:
      - mysql
    networks:
      - alerta-network
    restart: unless-stopped

networks:
  alerta-network:
    driver: bridge

volumes:
  mysql_data:
