version: "3.7"

services:
  mariadb:
    image: mariadb:10.3
    container_name: docker-thelia-mariadb
    working_dir: /application
    volumes:
      - .:/application
      - .docker/mysql-data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD
      - MYSQL_DATABASE
      - MYSQL_USER
      - MYSQL_PASSWORD
    ports:
      - "8086:3306"

  webserver:
    image: nginx:alpine
    container_name: docker-thelia-webserver
    working_dir: /application
    volumes:
      - .:/application
      - .docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
    ports:
      - "8080:80"

  php-fpm:
    build: .docker/php-fpm
    container_name: docker-thelia-php-fpm
    working_dir: /application
    volumes:
      - .:/application
      - .docker/php-fpm/php-ini-overrides.ini:/usr/local/etc/php/conf.d/99-overrides.ini
    environment:
      - PHP_IDE_CONFIG
      - XDEBUG_CONFIG
      - ACTIVE_FRONT_TEMPLATE
      - MYSQL_ROOT_PASSWORD
      - MYSQL_DATABASE
      - MYSQL_USER
      - MYSQL_PASSWORD

  encore:
    build:
      context: ./templates/frontOffice/${ACTIVE_FRONT_TEMPLATE:-modern}
      target: thelia_encore
    container_name: docker-thelia-encore
    working_dir: /application/templates/frontOffice/${ACTIVE_FRONT_TEMPLATE:-modern}
    environment:
      BROWSERSYNC_PROXY: http://localhost:8081
    volumes:
      - ./templates/frontOffice/${ACTIVE_FRONT_TEMPLATE:-modern}:/application/templates/frontOffice/${ACTIVE_FRONT_TEMPLATE:-modern}:delegated
      - ./templates/frontOffice/${ACTIVE_FRONT_TEMPLATE:-modern}/node_modules:/application/templates/frontOffice/${ACTIVE_FRONT_TEMPLATE:-modern}/node_modules
    ports:
      - 8081:8081