services:
  server:
    image: decisionrules/server
    environment:
      - "SHOWCASE=true"
      - "IN_MEMORY_RULE_COUNT=4"
      - "REDIS_URL=redis://host.docker.internal:6379"
      - "MONGO_DB_URI=mongodb://host.docker.internal:27017"
      - "CLIENT_URL=http://localhost:80/#"
      - "API_URL=http://host.docker.internal:8080"
      - "AI_ENGINE_URL=http://host.docker.internal:8084"
      - "LICENSE_KEY="
    ports:
      - "8080:8080"
      - "8081:8081"
    depends_on:
      mongoDb:
        condition: service_healthy
      redis:
        condition: service_started
    volumes:
      - license:/assets/lic/:rw


  client:
    image: decisionrules/client
    environment:
      - "SHOWCASE=true"
      - "API_URL=http://localhost:8080"
      - "BI_API_URL=http://localhost:8082"
    ports:
      - "80:80"
    depends_on:
      - server


  business-intelligence:
    image: decisionrules/business-intelligence
    environment:
      - "BI_MONGO_DB_URI=mongodb://host.docker.internal:27017"
    ports:
      - "8082:8082"
    depends_on:
      mongoDb:
        condition: service_healthy


  ai:
    image: decisionrules/ai-engine
    ports:
      - "8084:8084"


  mongoDb:
    image: mongo:8.0
    command: ["--replSet", "rs0", "--bind_ip_all"]
    ports:
      - "27017:27017"
    healthcheck:
      test: ["CMD", "mongosh", "--quiet", "--eval", "try { rs.status() } catch (e) { rs.initiate({ _id: 'rs0', members: [{ _id: 0, host: 'mongoDb:27017' }] }) }; quit(db.hello().isWritablePrimary ? 0 : 1)"]
      interval: 5s
      timeout: 10s
      retries: 30
      start_period: 5s


  redis:
    image: redis
    ports:
      - "6379:6379"
volumes:
  license:
    driver: local