version: '3.7'
services:
  phpdeps:
    image: prooph/composer:7.3
    volumes:
      - .:/app
    command: install
  assets:
    image: node:10
    volumes:
      - .:/usr/src/app
    working_dir: /usr/src/app
    command: bash -c "npm install && npm run watch"
  dependencies:
    depends_on:
      - "mgdb"
    image: php:7.3-cli-alpine
    volumes:
      - .:/data
    working_dir: /data
    command: /bin/sh -c "apk add --update dos2unix && dos2unix ./init.sh && ./init.sh && ./init.sh"
  mgdb:
    restart: on-failure
    image: mariadb:latest
    command: --default-authentication-plugin=mysql_native_password
    environment:
      - MYSQL_RANDOM_ROOT_PASSWORD=yes
      - MYSQL_USER=metager
      - MYSQL_PASSWORD=metager
      - MYSQL_DATABASE=metager
  redis:
    restart: on-failure
    image: redis:6.0-rc1-alpine
  phpfpm:
    depends_on:
      - "mgdb"
      - "dependencies"
      - "phpdeps"
      - "assets"
      - "redis"
    restart: on-failure
    build:
      context: .
      dockerfile: DockerfileDev
    image: metager:latest
    working_dir: /html
    volumes:
      - .:/html
  nginx:
    depends_on:
      - "phpfpm"
    restart: on-failure
    image: metager:latest
    working_dir: /html
    command: nginx
    volumes:
      - .:/html
      - ./config/nginx.conf:/etc/nginx/nginx.conf
      - ./config/nginx-default-dev.conf:/etc/nginx/conf.d/default.conf
    ports: 
    - "8080:80"
  worker:
    depends_on:
      - "phpfpm"
    restart: on-failure
    image: metager:latest
    working_dir: /html
    volumes:
      - .:/html
    command: "su -s /bin/sh -c 'php artisan requests:fetcher' nginx"
  test:
    depends_on:
      - "phpfpm"
    image: php:7.3-cli
    working_dir: /html
    volumes:
      - .:/html
    command: "php artisan dusk"
  dummy-phpfpm:
    restart: on-failure
    image: registry.metager.de/open-source/dummy-engine/master
    working_dir: /html
  dummy-nginx:
    depends_on:
      - "dummy-phpfpm"
    restart: on-failure
    image: registry.metager.de/open-source/dummy-engine/master
    working_dir: /html
    command: nginx