version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: tutoring_app
    restart: unless-stopped
    working_dir: /var/www
    volumes:
      - .:/var/www
    networks:
      - tutoring_network
    depends_on:
      - db
      - redis

  nginx:
    image: nginx:alpine
    container_name: tutoring_nginx
    restart: unless-stopped
    ports:
      - "8000:80"
    volumes:
      - .:/var/www
      - ./docker/nginx/conf.d:/etc/nginx/conf.d
    networks:
      - tutoring_network

  db:
    image: mysql:8.0
    container_name: tutoring_db
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: tutoring_db
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_PASSWORD: secret
      MYSQL_USER: tutoring_user
    ports:
      - "3306:3306"
    volumes:
      - db_data:/var/lib/mysql
    networks:
      - tutoring_network

  redis:
    image: redis:alpine
    container_name: tutoring_redis
    restart: unless-stopped
    networks:
      - tutoring_network

  mailpit:
    image: axllent/mailpit
    container_name: tutoring_mail
    ports:
      - "8025:8025"
      - "1025:1025"
    networks:
      - tutoring_network

volumes:
  db_data:

networks:
  tutoring_network:
    driver: bridge
