# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

services:
  tgi-service:
    image: ghcr.io/huggingface/tgi-gaudi:2.0.6
    container_name: tgi-gaudi-server
    ports:
      - "8008:80"
    environment:
      no_proxy: ${no_proxy}
      http_proxy: ${http_proxy}
      https_proxy: ${https_proxy}
      HUGGING_FACE_HUB_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
      HF_HUB_DISABLE_PROGRESS_BARS: 1
      HF_HUB_ENABLE_HF_TRANSFER: 0
      HABANA_VISIBLE_DEVICES: all
      OMPI_MCA_btl_vader_single_copy_mechanism: none
      ENABLE_HPU_GRAPH: true
      LIMIT_HPU_GRAPH: true
      USE_FLASH_ATTENTION: true
      FLASH_ATTENTION_RECOMPUTE: true
    healthcheck:
      test: ["CMD-SHELL", "sleep 500 && exit 0"]
      interval: 1s
      timeout: 505s
      retries: 1
    runtime: habana
    cap_add:
      - SYS_NICE
    ipc: host
    volumes:
      - "./data:/data"
    command: --model-id ${LLM_MODEL_ID} --max-input-length 1024 --max-total-tokens 2048
  llm:
    image: ${REGISTRY:-opea}/llm-textgen:${TAG:-latest}
    container_name: llm-textgen-gaudi-server
    depends_on:
      tgi-service:
        condition: service_healthy
    ports:
      - "9000:9000"
    ipc: host
    environment:
      no_proxy: ${no_proxy}
      http_proxy: ${http_proxy}
      https_proxy: ${https_proxy}
      LLM_ENDPOINT: ${TGI_LLM_ENDPOINT}
      LLM_MODEL_ID: ${LLM_MODEL_ID}
      HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
      HF_HUB_DISABLE_PROGRESS_BARS: 1
      HF_HUB_ENABLE_HF_TRANSFER: 0
    restart: unless-stopped
  translation-gaudi-backend-server:
    image: ${REGISTRY:-opea}/translation:${TAG:-latest}
    container_name: translation-gaudi-backend-server
    depends_on:
      - tgi-service
      - llm
    ports:
      - "8888:8888"
    environment:
      - no_proxy=${no_proxy}
      - https_proxy=${https_proxy}
      - http_proxy=${http_proxy}
      - MEGA_SERVICE_HOST_IP=${MEGA_SERVICE_HOST_IP}
      - LLM_SERVICE_HOST_IP=${LLM_SERVICE_HOST_IP}
    ipc: host
    restart: always
  translation-gaudi-ui-server:
    image: ${REGISTRY:-opea}/translation-ui:${TAG:-latest}
    container_name: translation-gaudi-ui-server
    depends_on:
      - translation-gaudi-backend-server
    ports:
      - "5173:5173"
    environment:
     - no_proxy=${no_proxy}
      - https_proxy=${https_proxy}
      - http_proxy=${http_proxy}
      - BASE_URL=${BACKEND_SERVICE_ENDPOINT}
    ipc: host
    restart: always
  translation-gaudi-nginx-server:
    image: ${REGISTRY:-opea}/nginx:${TAG:-latest}
    container_name: translation-gaudi-nginx-server
    depends_on:
      - translation-gaudi-backend-server
      - translation-gaudi-ui-server
    ports:
      - "${NGINX_PORT:-80}:80"
    environment:
      - no_proxy=${no_proxy}
      - https_proxy=${https_proxy}
      - http_proxy=${http_proxy}
      - FRONTEND_SERVICE_IP=${FRONTEND_SERVICE_IP}
      - FRONTEND_SERVICE_PORT=${FRONTEND_SERVICE_PORT}
      - BACKEND_SERVICE_NAME=${BACKEND_SERVICE_NAME}
      - BACKEND_SERVICE_IP=${BACKEND_SERVICE_IP}
      - BACKEND_SERVICE_PORT=${BACKEND_SERVICE_PORT}
    ipc: host
    restart: always

networks:
  default:
    driver: bridge
