version: "3" 
services:
  apache:
    build: './apache/'
    depends_on:
      - php
      - db
    networks:
      - frontend
      - backend
    ports:
      - "8222:80"
    volumes:
      - "./app/:/var/www/html/"
  # Web service layer
  # nginx:
  #   image: nginx:1.13
  #   networks:
  #     - backend
  #   volumes:
  #     - "./app:/var/www/html"
  #     - "./nginx/nginx.conf:/etc/nginx/nginx.conf"
  #   ports:
  #     - "8111:80"
  #   depends_on:
  #     - php

  # Application service layer
  php:
    build:
      context: ./php
    volumes:
      - "./app:/var/www/html"
    networks:
      - backend
    ports:
      - "9000"
    depends_on:
      - db
    environment:
      - DB_USER=root
      - DB_PASS=123.456
  
  # Data persistence service layer
  db:
    build:
      context: ./mysql
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=123.456
    volumes:
      - "./mysql/vol:/var/lib/mysql"
    networks:
      - backend
    ports:
      - "3306"
networks:
  frontend:
  backend: