services:
  php:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    container_name: jo2024-docker_php
    working_dir: /var/www/symfony
    volumes:
      - ./app:/var/www/symfony:cached
      - ./app/var/coverage:/var/www/symfony/var/coverage
      - ./app/docs:/var/www/symfony/app/docs:cached
      - ./app/.env.docker.local:/var/www/symfony/.env.local:ro
      - ./app/.env.test.local:/var/www/symfony/.env.test.local:ro
    environment:
      - APP_ENV=dev
      - COMPOSER_ALLOW_SUPERUSER=1
    depends_on:
      - db
      - redis
    networks:
      - symfony

  web:
    image: nginx:alpine
    container_name: jo2024-docker_nginx
    ports:
      - "8080:80"
    volumes:
      - ./app:/var/www/symfony:cached
      - ./docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - php
    networks:
      - symfony

  db:
    image: mysql:8.0
    container_name: jo2024-docker_db
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: jo2024
      MYSQL_USER: jo2024
      MYSQL_PASSWORD: jo2024
    ports:
      - "3307:3306"
    volumes:
      - db_data:/var/lib/mysql
      - ./docker/mysql/init:/docker-entrypoint-initdb.d
    networks:
      - symfony

  redis:
    image: redis:alpine
    container_name: jo2024-docker_redis
    ports:
      - "6379:6379"
    networks:
      - symfony

  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    container_name: jo2024-docker_pma
    environment:
      PMA_HOST: db
      PMA_USER: jo2024
      PMA_PASSWORD: jo2024
    ports:
      - "8081:80"
    depends_on:
      - db
    networks:
      - symfony

  mailhog:
    image: mailhog/mailhog
    container_name: jo2024-docker_mailhog
    ports:
      - "1025:1025"
      - "8025:8025"
    networks:
      - symfony

volumes:
  db_data:

networks:
  symfony:
    driver: bridge
