version: '3.8'

services:
  backend-a:
    build:
      context: ../backend/
      dockerfile: ../deploy/dev/Dockerfile.backend
    volumes:
      - ../backend:/code
      - ../deploy/dev/instance_a/a.env:/code/.env
      - ../deploy/dev/instance_a/testdata.py:/code/testdata.py
      - ../deploy/dev/instance_a/a.sqlite3:/code/db.sqlite3
    expose:
      - 8000
    command: bash -c "python configure.py; python configure.py testdata; python manage.py runserver 0.0.0.0:8000 --insecure"

  backend-b:
    build:
      context: ../backend/
      dockerfile: ../deploy/dev/Dockerfile.backend
    volumes:
      - ../backend:/code
      - ../deploy/dev/instance_b/b.env:/code/.env
      - ../deploy/dev/instance_b/testdata.py:/code/testdata.py
      - ../deploy/dev/instance_b/b.sqlite3:/code/db.sqlite3
    expose:
      - 8000
    command: bash -c "python configure.py; python configure.py testdata; python manage.py runserver 0.0.0.0:8000 --insecure"

  frontend:
    build:
      context: ../frontend/
      dockerfile: ../deploy/dev/Dockerfile.frontend
    volumes:
      - ../frontend:/app
      - /app/node_modules
    expose:
      - 5173
    command: bash -c "npm install && npm run dev -- --host"

  wiki:
    build:
      context: ../
      dockerfile: deploy/dev/Dockerfile.wiki
    volumes:
      - ../mkdocs.yml:/wiki/mkdocs.yml
      - ../docs:/wiki/docs
    expose:
      - 8001
    command: mkdocs serve --dev-addr=0.0.0.0:8001

  proxy-a:
    build:
      context: ./
      dockerfile: dev/Dockerfile.proxy
    volumes:
      - ./dev/instance_a/nginx-a.dev.conf:/etc/nginx/nginx.conf:ro
      - ./dev/instance_a/dns.json:/var/www/dns.json:ro
      - ./dev/instance_a/domains.json:/var/www/domains.json:ro
    ports:
      - "127.0.0.1:8080:8080"
      - "127.0.0.3:5353:5353"

  proxy-b:
    build:
      context: ./
      dockerfile: dev/Dockerfile.proxy
    volumes:
      - ./dev/instance_b/nginx-b.dev.conf:/etc/nginx/nginx.conf:ro
    ports:
      - "127.0.0.2:8080:8080"

  dns:
    build:
      context: ./dev/
      dockerfile: Dockerfile.dns
    volumes:
      - ./dev/zone.json:/dns/zone.json
    expose:
      - 8053