---
include:
  - docker/docker-compose.services.yml

services:

  backend:
    container_name: ark-backend
    build: .

    depends_on:
      - db
      - redis
      - lb

    labels:
      traefik.enable: true
      traefik.http.routers.backend.rule: Host(`ark.localhost`) && (PathPrefix(`/api/`) || PathPrefix(`/api-docs/`) || PathPrefix(`/admin/`) || PathPrefix(`/rq/`) || PathPrefix(`/static/`))
      traefik.http.routers.backend.tls: true

    environment:
      CONFIG_PATH: /arkindex.yml

    volumes:
      - ./docker/config.yml:/arkindex.yml:ro

    healthcheck:
      # start_interval is not fully implemented in Docker, until then we will use a short interval all the time
      # https://github.com/moby/moby/issues/45897
      interval: 5s

  worker:
    container_name: ark-worker
    build: .
    command: arkindex rqworker-pool --num-workers 2 -v 1 default high tasks export

    depends_on:
      - db
      - redis
      - backend
    environment:
      CONFIG_PATH: /arkindex.yml

    volumes:
      - ./docker/config.yml:/arkindex.yml:ro

      # Required to host temporary ponos data
      # and share common paths between host and containers
      - /tmp:/tmp

      # Required to run process tasks
      - /var/run/docker.sock:/var/run/docker.sock

  front:
    container_name: ark-front

    build: ../frontend

    depends_on:
      - lb
      - backend

    labels:
      traefik.enable: true
      traefik.http.routers.frontend.rule: Host(`ark.localhost`)
      traefik.http.routers.frontend.tls: true
