version: '2.4'

services:
  proxy:
    image: nginxproxy/nginx-proxy:alpine
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
    ports:
      - 80:80

  app:
    build:
      context: .
      dockerfile: tools/docker/images/Dockerfile
      target: app
    expose:
      - 80
    command:
      - generate
      - --server
      - --watch
      - --port
      - '80'
      - --url
      - http://oliverdavies.localhost
    volumes:
      - assets:/app/source/build
      - /app/output_dev
      - .:/app
    environment:
      VIRTUAL_HOST: oliverdavies.localhost

  phpunit:
    build:
      context: .
      dockerfile: tools/docker/images/Dockerfile
      target: app
    volumes:
      - .:/app
    entrypoint: ["phpunit"]

  assets:
    image: node:14
    volumes:
      - assets:/node/source/build
      - /node/node_modules
      - ./assets:/node/assets
      - ./Makefile:/node/Makefile
      - ./package.json:/node/package.json
      - ./package-lock.json:/node/package-lock.json
      - ./postcss.config.js:/node/postcss.config.js
      - ./source:/node/source
      - ./tailwind.config.js:/node/tailwind.config.js
      - ./tools/tailwindcss:/node/tools/tailwindcss
      - ./webpack.config.js:/node/webpack.config.js
    working_dir: /node
    entrypoint: make
    command:
      - assets-watch

volumes:
  assets: