# version: '3.9'

services:

  mysql:
    image: mysql:latest
    restart: always
    container_name: ${PROJECT}_MYSQL
    volumes:
      - ./db/sql:/docker-entrypoint-initdb.d/
      - ./db/data:/var/lib/mysql
    environment:
      MYSQL_DATABASE: ${DB}
      MYSQL_USER: ${DBU}
      MYSQL_PASSWORD: '${DBP}'
      MYSQL_ROOT_PASSWORD: '${DBR}'
    ports:
      - "${DB_P}:3306"
    networks:
      - ${PROJECT}net

  pma:
    image: phpmyadmin/phpmyadmin
    restart: always
    container_name: ${PROJECT}_PMA
    environment:
      PMA_HOST: ${DBH}
      PMA_USER: ${DBU}
      PMA_PASSWORD: ${DBP}
      PHP_UPLOAD_MAX_FILESIZE: 1G
      UPLOAD_LIMIT: 1G
      PHP_MAX_INPUT_VARS: 1G
      PMA_ARBITRARY: 1
    depends_on:
      - mysql
    ports:
      - "${PMA_P}:80"
    networks:
      - ${PROJECT}net

  drupal:
    build: .
    # image: drupal:latest
    restart: always
    container_name: ${PROJECT}_DRUPAL
    working_dir: /opt/drupal
    volumes:
      - .:/opt/drupal:z
    environment:
      DB_HOST: ${DBH}
      DB_NAME: ${DB}
      DB_USER: ${DBU}
      DB_PASS: ${DBP}
    depends_on:
     - mysql
#    command: bash -c "composer update && rm -fR /var/www/html && ln -s /opt/drupal/web /var/www/html && /usr/local/bin/apache2-foreground"
    ports:
      - "${WEB_P}:80"
    networks:
      - ${PROJECT}net

networks:
  autreatiesnet:
    name: ${PROJECT}net
    driver: bridge

#  volumes:
#    drupaldata:
#    mysqldata:
