version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: condominio_app
    restart: unless-stopped
    working_dir: /var/www
    volumes:
      - ./:/var/www
      - ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini
    networks:
      - condominio_network
    depends_on:
      - db
      - redis

  nginx:
    image: nginx:alpine
    container_name: condominio_nginx
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - ./:/var/www
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
    networks:
      - condominio_network
    depends_on:
      - app

  db:
    image: mysql:8.0
    container_name: condominio_db
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: condominio_management
      MYSQL_ROOT_PASSWORD: root_password
      MYSQL_USER: condominio_user
      MYSQL_PASSWORD: condominio_password
    volumes:
      - db_data:/var/lib/mysql
    ports:
      - "3306:3306"
    networks:
      - condominio_network

  redis:
    image: redis:alpine
    container_name: condominio_redis
    restart: unless-stopped
    ports:
      - "6379:6379"
    networks:
      - condominio_network

  mailhog:
    image: mailhog/mailhog
    container_name: condominio_mailhog
    ports:
      - "1025:1025"
      - "8025:8025"
    networks:
      - condominio_network

volumes:
  db_data:

networks:
  condominio_network:
    driver: bridge