version: '3.8'

services:
  frontend:
    build: .
    container_name: yii2-frontend
    ports:
      - "8080:80"
    volumes:
      - .:/var/www/html
    depends_on:
      - db
    environment:
      APP_TYPE: frontend

  backend:
    build: .
    container_name: yii2-backend
    ports:
      - "8081:80"
    volumes:
      - .:/var/www/html
    depends_on:
      - db
    environment:
      APP_TYPE: backend

  db:
    image: mysql:5.7
    container_name: yii2-db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: yii2
      MYSQL_USER: yii2user
      MYSQL_PASSWORD: yii2pass
    ports:
      - "3307:3306"
    volumes:
      - db_data:/var/lib/mysql

volumes:
  db_data:
