version: '3.8'
services:
  
  # PHP server
  php:
    container_name: assetise-php
    build:
      context: .
      target: php
      args: 
        - APP_ENV=${APP_ENV}
    environment:
      - APP_ENV=${APP_ENV}
      - CONTAINER_ROLE=app
    working_dir: /var/www
    volumes:
      - ./:/var/www
      - ./php/local.ini:/usr/local/etc/php/conf.d/php.ini
    ports:
      - "8000:8000"
    depends_on:
      - Database

  # Database server
  Database:
    container_name: assetise-database
    image: mysql:8.4
    ports:
      - 3306:3306
    environment:
      - MYSQL_DATABASE=${DB_DATABASE}
      - MYSQL_USER=${DB_USERNAME}
      - MYSQL_PASSWORD=${DB_PASSWORD}
      - MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
    volumes:
      - db-data:/var/lib/mysql

  # PhpMyAdmin server
  phpmyadmin:
    container_name: assetise-phpmyadmin
    image: phpmyadmin/phpmyadmin
    links:
      - Database
    environment:
      PMA_HOST: Database
      PMA_PORT: 3306
      PMA_ARBITRARY: 1
      UPLOAD_LIMIT: 102400K
    restart: always
    ports:
      - 8183:80

volumes:
  db-data: ~