x-svc: &service
  env_file:
    - "run/env/service.env"
  volumes:
    - vol:/vol
    - conf:/wmsa/conf:ro
    - model:/wmsa/model
    - logs:/var/log/wmsa
  networks:
    - wmsa
  depends_on:
    - mariadb

services:
  index-service:
    <<: *service
    image: "marginalia.nu/index-service"
    container_name: "index-service"
    ports:
      - "127.0.0.1:5021:5021/tcp"
      - "127.0.0.1:4021:5000"
      - "127.0.0.1:7021:4000"
  search-service:
    <<: *service
    image: "marginalia.nu/search-service"
    container_name: "search-service"
    ports:
      - "127.0.0.1:5023:5023"
      - "127.0.0.1:4023:5000"
      - "127.0.0.1:7023:4000"
    depends_on:
      - index-service
  assistant-service:
    <<: *service
    image: "marginalia.nu/assistant-service"
    container_name: "assistant-service"
    ports:
      - "127.0.0.1:5025:5025"
      - "127.0.0.1:4025:5000"
      - "127.0.0.1:7025:4000"
    depends_on:
      - mariadb
  api-service:
    <<: *service
    image: "marginalia.nu/api-service"
    container_name: "api-service"
    ports:
      - "127.0.0.1:5004:5025"
      - "127.0.0.1:4004:5000"
      - "127.0.0.1:7004:4000"
    depends_on:
      - mariadb
  dating-service:
    <<: *service
    image: "marginalia.nu/dating-service"
    container_name: "dating-service"
    ports:
      - "127.0.0.1:5070:5070"
      - "127.0.0.1:4070:5000"
      - "127.0.0.1:7070:4000"
    depends_on:
      - mariadb
  explorer-service:
    <<: *service
    image: "marginalia.nu/explorer-service"
    container_name: "explorer-service"
    ports:
      - "127.0.0.1:5071:5071"
      - "127.0.0.1:4071:5000"
      - "127.0.0.1:7071:4000"
    depends_on:
      - mariadb
  mariadb:
    image: "mariadb/server:10.3"
    container_name: "mariadb"
    env_file: "run/env/mariadb.env"
    command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']
    ports:
      - "127.0.0.1:3306:3306/tcp"
    volumes:
      - db:/var/lib/mysql
      - "./code/common/model/src/main/resources/sql/edge-crawler-cache.sql:/docker-entrypoint-initdb.d/init.sql"
    networks:
      - wmsa
  nginx-gw:
    image: "nginx"
    container_name: "nginx-gw"
    ports:
      - "127.0.0.1:8080:80"
    volumes:
      - "./run/nginx-site.conf:/etc/nginx/conf.d/default.conf"
    networks:
      - wmsa
    depends_on:
      - search-service
networks:
  wmsa:
volumes:
  db:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: run/db
  vol:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: run/vol
  logs:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: run/logs
  model:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: run/model
  conf:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: run/conf
