services:
  # Web Server - Apache with PHP
  web:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: townoffriendship_web
    ports:
      - "${WEB_PORT}:80"
    volumes:
      - .:/var/www/html
    depends_on:
      - db
    environment:
      - DB_HOST=${DB_HOST}
      - DB_PORT=${DB_PORT}
      - DB_NAME=${DB_NAME}
      - DB_USER=${DB_USER}
      - DB_PASSWORD=${DB_PASSWORD}
    networks:
      - app-network
    restart: unless-stopped

  # MySQL Database
  db:
    image: mysql:8.0
    container_name: townoffriendship_db
    ports:
      - "3306:3306"
    environment:
      - MYSQL_DATABASE=${DB_NAME}
      - MYSQL_USER=${DB_USER}
      - MYSQL_PASSWORD=${DB_PASSWORD}
      - MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
    volumes:
      - db-data:/var/lib/mysql
    networks:
      - app-network
    restart: unless-stopped

  # Future Services (Scaffolded)

  # Email Service - MailHog for local mail testing
  mailhog:
    image: mailhog/mailhog
    container_name: townoffriendship_mailhog
    ports:
      - "${MAIL_PORT}:1025"  # SMTP port
      - "8025:8025"          # Web UI port
    networks:
      - app-network
    restart: unless-stopped

  # S3 Storage - MinIO for local S3-compatible storage
  minio:
    image: minio/minio
    container_name: townoffriendship_minio
    ports:
      - "9000:9000"  # API port
      - "9001:9001"  # Console port
    environment:
      - MINIO_ROOT_USER=${S3_KEY}
      - MINIO_ROOT_PASSWORD=${S3_SECRET}
    volumes:
      - minio-data:/data
    command: server /data --console-address ":9001"
    networks:
      - app-network
    restart: unless-stopped

networks:
  app-network:
    driver: bridge

volumes:
  db-data:
  minio-data:
