version: '3'

services:
  web:
    container_name: "troaby"
    build:
      context: ../../
      dockerfile: Dockerfile
    ports:
      - 80:80
      - 3000:3000
    volumes:
      - ../../:/var/html/www/
      - ./vhost.conf:/opt/docker/etc/httpd/vhost.conf
    depends_on:
      - mysql
    environment:
      - WEB_DOCUMENT_ROOT=/var/html/www/public
      - WEB_DOCUMENT_INDEX=index.php
    extra_hosts:
      - "troaby.vm:127.0.0.1"
      - "www.troaby.vm:127.0.0.1"
  mysql:
    container_name: "troaby_mysql"
    build:
      context: ./mysql
      dockerfile: Dockerfile
    ports:
      - 3306:3306
    environment:
      - MYSQL_ROOT_PASSWORD=root_psw # root user password
      - MYSQL_USER=mysql_user        # user
      - MYSQL_PASSWORD=mysql_psw     # user password
      - MYSQL_DATABASE=mysql_db      # database to create
    volumes:
      # Use binded volume to prevent multiple anonymous
      # volumes from being generated by the image Dockerfile
      - ./mysql/volume:/var/lib/mysql
