version: '2.4'

services:
  proxy:
    image: traefik:v2.0-alpine
    command:
      - --api.insecure=true
      - --providers.docker
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - 80:80
      - 8080:8080
    labels:
      - "traefik.enable=false"

  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
    labels:
      - "traefik.http.routers.oliverdavies.rule=Host(`oliverdavies.localhost`)"

  assets:
    image: node:14
    volumes:
      - assets:/node/source/build
      - /node/node_modules
      - ./assets:/node/assets
      - ./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
    entrypoint: npm
    command: run watch
    labels:
      - "traefik.enable=false"

volumes:
  assets: