version: '3'
services:
  mysql:
    container_name: mysql
    image: mysql:5.7
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
      - MYSQL_PASSWORD=${DB_PASSWORD}
      - MYSQL_DATABASE=${DB_DATABASE}
    ports:
      - '${DB_PORT}:3306'
    volumes:
      #dump into database
      - ./mysql:/docker-entrypoint-initdb.d
      - ilead-pm-mysql-data:/var/lib/mysql
    command: --default-authentication-plugin=mysql_native_password --sql_mode=""
  app:
    container_name: ilead-pm
    build:
      context: .
      dockerfile: dev.Dockerfile
      args:
        SSH_KEY: ${SSH_PRIVATE_KEY}
    restart: always
    ports:
      - '8080:80'
      - '8000:8000'
    volumes:
      - ./user:/var/www/html/user
      - node_modules:/var/www/html/user/node_modules
      - ./api:/var/www/html/api
      - ./.env:/var/www/html/api/.env
      - vendor:/var/www/html/api/vendor
      - laravel_vendor:/var/www/html/api/laravel/vendor
    depends_on:
      - mysql
    environment:
      - APP_ENV=${APP_ENV}
volumes:
  ilead-pm-mysql-data:
  node_modules:
  vendor:
  laravel_vendor:
