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

services:
  textgen:
    image: ${REGISTRY:-opea}/llm-textgen:${TAG:-latest}
    container_name: llm-textgen-server
    ports:
      - ${TEXTGEN_PORT:-9000}:9000
    ipc: host
    environment:
      no_proxy: ${no_proxy},tgi-service,llm-textgen-server
      http_proxy: ${http_proxy}
      https_proxy: ${https_proxy}
      LLM_ENDPOINT: "http://tgi-service:80"
      LLM_MODEL_ID: ${LLM_MODEL_ID}
      HF_TOKEN: ${HF_TOKEN}
      LOGFLAG: ${LOGFLAG:-False}
    depends_on:
      tgi-service:
        condition: service_healthy
    restart: unless-stopped

  tgi-service:
    image: ghcr.io/huggingface/text-generation-inference:3.2.3-intel-cpu
    container_name: tgi-service
    ports:
      - "9009:80"
    volumes:
      - "./data:/data"
    shm_size: 1g
    environment:
      no_proxy: ${no_proxy},tgi-service,llm-textgen-server
      http_proxy: ${http_proxy}
      https_proxy: ${https_proxy}
      HF_TOKEN: ${HF_TOKEN}
      HF_HUB_DISABLE_PROGRESS_BARS: 1
      HF_HUB_ENABLE_HF_TRANSFER: 0
    command: --model-id ${LLM_MODEL_ID} --cuda-graphs 0
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:80/health"]
      interval: 10s
      timeout: 6s
      retries: 48

networks:
  default:
    driver: bridge
