version: '3'

services:
  mysql:
    image: mysql:5.7
    volumes:
      - "./storage/mysql:/var/lib/mysql"
      - "./storage/logs/mysql:/var/log/mysql"
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-pass4dev}
      - MYSQL_DATABASE=${MYSQL_DATABASE:-db4dev}
      - MYSQL_USER=${MYSQL_USER:-user4dev}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD:-pass4dev}
    restart: always

  php_fpm:
    build:
      context: ./php_fpm
    depends_on:
      - mysql
    volumes:
      - "../htdocs/wp-content:/var/www/html/wp-content"
      - "../htdocs/wp-config.php:/var/www/html/wp-config.php"
      - "htdocs:/var/www/html"
    environment:
      - DB_NAME=${DB_NAME:-db4dev}
      - DB_USER=${DB_USER:-user4dev}
      - DB_PASSWORD=${DB_PASSWORD:-pass4dev}
      - DB_HOST=${DB_HOST:-mysql}
    restart: always

  nginx:
    image: nginx:1.15-alpine
    depends_on:
      - php_fpm
    volumes:
      - "./nginx/nginx.conf:/etc/nginx/nginx.conf:ro"
      - "./storage/logs/nginx:/var/log/nginx"
      - "../htdocs/wp-content:/var/www/html/wp-content"
      - "../htdocs/wp-config.php:/var/www/html/wp-config.php:ro"
      - "htdocs:/var/www/html"
    restart: always

volumes:
  htdocs: