version:  '3.7'

services:
  mysql:
    image: mysql:8.0
    restart: on-failure
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
    volumes:
      - db-data:/var/lib/mysql
    ports:
      - "3310:3306"

  nginx:
    image: nginx:alpine
    restart: on-failure
    depends_on:
      - php
    volumes:
      - '../:/srv'
      - './nginx/config/nginx.conf:/etc/nginx/conf.d/default.conf:ro'
    ports:
      - '8005:80'

  php:
    build:
      context: ./php
      dockerfile: ./Dockerfile
    volumes:
      - '../:/srv'
    environment:
      PHP_VERSION: 7.4
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
      PHP_FPM_CLEAR_ENV: "no"
      DB_HOST: mysql
      DB_USER: ${MYSQL_USER}
      DB_PASSWORD: ${MYSQL_PASSWORD}
      DB_NAME: ${MYSQL_DATABASE}
      DB_DRIVER: mysql
    restart: on-failure

volumes:
  db-data: {}
