version: '3.8'

services:
  rocketchat:
    volumes:
      - /tmp/coverage:/tmp/coverage
    platform: linux/amd64
    build:
      dockerfile: ${RC_DOCKERFILE}
      context: /tmp/build
      args:
        DENO_VERSION: ${DENO_VERSION}
    image: ghcr.io/${LOWERCASE_REPOSITORY}/rocket.chat:${RC_DOCKER_TAG}
    environment:
      - TEST_MODE=true
      - DEBUG=${DEBUG}
      - EXIT_UNHANDLEDPROMISEREJECTION=true
      - 'MONGO_URL=${MONGO_URL}'
      - 'MONGO_OPLOG_URL=${MONGO_OPLOG_URL}'
      - 'TRANSPORTER=${TRANSPORTER}'
      - MOLECULER_LOG_LEVEL=info
      - 'ROCKETCHAT_LICENSE=${ENTERPRISE_LICENSE}'
      - 'COVERAGE_DIR=${COVERAGE_DIR}'
      - 'COVERAGE_REPORTER=${COVERAGE_REPORTER}'
      - DISABLE_DB_WATCHERS=${DISABLE_DB_WATCHERS}
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    depends_on:
      - traefik
    labels:
      traefik.enable: true
      traefik.http.services.rocketchat.loadbalancer.server.port: 3000
      traefik.http.routers.rocketchat.service: rocketchat
      traefik.http.routers.rocketchat.rule: PathPrefix(`/`)
      traefik.http.middlewares.test-retry.retry.attempts: 4

  authorization-service:
    platform: linux/amd64
    build:
      dockerfile: ee/apps/authorization-service/Dockerfile
      context: .
      args:
        SERVICE: authorization-service
        DENO_VERSION: ${DENO_VERSION}
    image: ghcr.io/${LOWERCASE_REPOSITORY}/authorization-service:${DOCKER_TAG}
    environment:
      - 'MONGO_URL=${MONGO_URL}'
      - 'TRANSPORTER=${TRANSPORTER}'
      - MOLECULER_LOG_LEVEL=info
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    depends_on:
      - nats

  account-service:
    platform: linux/amd64
    build:
      dockerfile: ee/apps/account-service/Dockerfile
      context: .
      args:
        SERVICE: account-service
    image: ghcr.io/${LOWERCASE_REPOSITORY}/account-service:${DOCKER_TAG}
    environment:
      - MONGO_URL=${MONGO_URL}
      - 'TRANSPORTER=${TRANSPORTER}'
      - MOLECULER_LOG_LEVEL=info
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    depends_on:
      - nats

  presence-service:
    platform: linux/amd64
    build:
      dockerfile: ee/apps/presence-service/Dockerfile
      context: .
      args:
        SERVICE: presence-service
        DENO_VERSION: ${DENO_VERSION}
    image: ghcr.io/${LOWERCASE_REPOSITORY}/presence-service:${DOCKER_TAG}
    environment:
      - MONGO_URL=${MONGO_URL}
      - 'TRANSPORTER=${TRANSPORTER}'
      - MOLECULER_LOG_LEVEL=info
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    depends_on:
      - nats

  ddp-streamer-service:
    platform: linux/amd64
    build:
      dockerfile: ee/apps/ddp-streamer/Dockerfile
      context: .
      args:
        SERVICE: ddp-streamer
    image: ghcr.io/${LOWERCASE_REPOSITORY}/ddp-streamer-service:${DOCKER_TAG}
    environment:
      - MONGO_URL=${MONGO_URL}
      - 'TRANSPORTER=${TRANSPORTER}'
      - MOLECULER_LOG_LEVEL=info
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    depends_on:
      - nats
      - traefik
    labels:
      traefik.enable: true
      traefik.http.services.ddp-streamer-service.loadbalancer.server.port: 3000
      traefik.http.routers.ddp-streamer-service.service: ddp-streamer-service
      traefik.http.routers.ddp-streamer-service.rule: PathPrefix(`/websocket`) || PathPrefix(`/sockjs`)

  stream-hub-service:
    platform: linux/amd64
    build:
      dockerfile: ee/apps/stream-hub-service/Dockerfile
      context: .
      args:
        SERVICE: stream-hub-service
    image: ghcr.io/${LOWERCASE_REPOSITORY}/stream-hub-service:${DOCKER_TAG}
    environment:
      - MONGO_URL=${MONGO_URL}
      - 'TRANSPORTER=${TRANSPORTER}'
      - MOLECULER_LOG_LEVEL=info
      - DISABLE_DB_WATCHERS=${DISABLE_DB_WATCHERS}
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    depends_on:
      - nats

  queue-worker-service:
    platform: linux/amd64
    build:
      dockerfile: ee/apps/queue-worker/Dockerfile
      context: .
      args:
        SERVICE: queue-worker
    image: ghcr.io/${LOWERCASE_REPOSITORY}/queue-worker-service:${DOCKER_TAG}
    environment:
      - MONGO_URL=${MONGO_URL}
      - 'TRANSPORTER=${TRANSPORTER}'
      - MOLECULER_LOG_LEVEL=info
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    depends_on:
      - nats

  omnichannel-transcript-service:
    platform: linux/amd64
    build:
      dockerfile: ee/apps/omnichannel-transcript/Dockerfile
      context: .
      args:
        SERVICE: omnichannel-transcript
    image: ghcr.io/${LOWERCASE_REPOSITORY}/omnichannel-transcript-service:${DOCKER_TAG}
    environment:
      - TEST_MODE=true
      - MONGO_URL=${MONGO_URL}
      - 'TRANSPORTER=${TRANSPORTER}'
      - MOLECULER_LOG_LEVEL=info
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    depends_on:
      - nats

  nats:
    image: nats:2.6-alpine

  traefik:
    image: traefik:v3.1
    command:
      - --providers.docker=true
      - '--serverstransport.maxidleconnsperhost=-1'
    ports:
      - 3000:80
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
