version: '3.8'

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

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

  db:
    image: mysql:8.0
    container_name: tours-travel-db
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: ${DB_DATABASE:-tours_travel}
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-password}
      MYSQL_USER: ${DB_USERNAME:-tours_user}
      MYSQL_PASSWORD: ${DB_PASSWORD:-password}
    ports:
      - "3307:3306"
    volumes:
      - db-data:/var/lib/mysql
    networks:
      - tours-network

  redis:
    image: redis:alpine
    container_name: tours-travel-redis
    restart: unless-stopped
    ports:
      - "6380:6379"
    networks:
      - tours-network

  mailpit:
    image: axllent/mailpit
    container_name: tours-travel-mail
    restart: unless-stopped
    ports:
      - "8025:8025"
      - "1025:1025"
    networks:
      - tours-network

networks:
  tours-network:
    driver: bridge

volumes:
  db-data:
