version: "2"
services:

  php:
    image: wodby/drupal-php:${PHP_VERSION}
    environment:
      DB_HOST: db
      DB_USER: drupal
      DB_PASSWORD: drupal
      DB_NAME: drupal
      DB_DRIVER: mysql
      PHP_FPM_USER: wodby
      PHP_FPM_GROUP: wodby
      PHP_FPM_CLEAR_ENV: "yes"
      PHP_OPCACHE_PRELOAD_USER: wodby
      PHP_XDEBUG_MODE: "off"
      PHP_XDEBUG_REMOTE_CONNECT_BACK: 1
      PHP_XDEBUG_REMOTE_HOST: "10.254.254.254"
      PHP_XDEBUG_IDEKEY: "PHPSTORM"
      PHP_IDE_CONFIG: "serverName=drupalextension"
    volumes:
      - ./:/var/www/html
    labels:
      - "traefik.enable=false"
    depends_on:
      - proxy

  proxy:
    image: traefik:v2.10
    command:
      - "--api.insecure=true"
      - "--providers.docker"
      - "--entrypoints.http-80.address=:80"
      - "--entrypoints.http-443.address=:443"
    ports:
      - "80:80"
      - "443:443"
      # The Web UI (enabled by --api.insecure=true)
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    labels:
      - "traefik.enable=false"

  drupal:
    image: wodby/nginx
    depends_on:
      - php
    environment:
      NGINX_STATIC_OPEN_FILE_CACHE: "off"
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_BACKEND_HOST: php
      NGINX_SERVER_ROOT: /var/www/html/drupal
      NGINX_VHOST_PRESET: drupal10
    volumes:
      - ./:/var/www/html
    labels:
      - "traefik.http.routers.drupal.rule=Host(`proxy`)"
      - "traefik.http.routers.drupal.entrypoints=http-80"
      - "traefik.http.routers.drupal-secure.rule=Host(`proxy`)"
      - "traefik.http.routers.drupal-secure.tls=true"
      - "traefik.http.routers.drupal-secure.entrypoints=http-443"

  blackbox:
    image: wodby/nginx
    environment:
      NGINX_STATIC_OPEN_FILE_CACHE: "off"
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_SERVER_ROOT: /var/www/html/fixtures/blackbox
      NGINX_VHOST_PRESET: html
    volumes:
      - ./:/var/www/html
    labels:
      - "traefik.enable=false"

  db:
    image: wodby/mariadb:10.3-3.8.4
    stop_grace_period: 30s
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: drupal
      MYSQL_USER: drupal
      MYSQL_PASSWORD: drupal
    labels:
      - "traefik.enable=false"

  node:
    image: node:latest
    user: "node"
    working_dir: /home/node/app
    environment:
      - NODE_ENV="production npm run production"
      - SHELL=bash
    volumes:
      - ./:/home/node/app
    command: "sleep infinity"
    labels:
      - "traefik.enable=false"
