Mar05a

Young-Kyoo Kim·2026년 3월 5일
# ── 경량 챗봇 이미지 (추론 전용) ──
# 베이스: python:3.11-slim
# Airgap: FROM nexus.internal:8082/docker-proxy/python:3.11-slim

FROM python:3.11-slim

ARG NEXUS_PYPI=https://pypi.org/simple
ARG NEXUS_TORCH=https://download.pytorch.org/whl/cpu

WORKDIR /app

# ── OS 최소 패키지 ──
RUN apt-get update && apt-get install -y --no-install-recommends \
      curl libgomp1 \
    && rm -rf /var/lib/apt/lists/*

# ── Python 의존성 ──
COPY app/requirements.txt .

RUN pip install --no-cache-dir \
      --index-url ${NEXUS_PYPI} \
      --extra-index-url ${NEXUS_TORCH} \
      torch==2.3.1+cpu && \
    pip install --no-cache-dir \
      --index-url ${NEXUS_PYPI} \
      -r requirements.txt && \
    pip cache purge

# ── 앱 소스 ──
COPY app/main.py .

# ── (선택) 임베딩 모델을 이미지에 포함
#    - 포함하면 PVC 불필요 / 이미지 크기 +400MB
#    - 제외하면 PVC 마운트로 /app/models 제공
# COPY models/all-MiniLM-L6-v2 /app/models/all-MiniLM-L6-v2

# ── 비루트 사용자 ──
RUN useradd -m -u 1000 app && chown -R app:app /app
USER app

EXPOSE 8501

HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
  CMD curl -f http://localhost:8501/_stcore/health || exit 1

ENV OLLAMA_BASE_URL="http://ollama-svc:11434" \
    OLLAMA_MODEL="llama3" \
    MILVUS_HOST="milvus-svc" \
    MILVUS_PORT="19530" \
    COLLECTION_NAME="aistor_docs" \
    EMBEDDING_MODEL_PATH="/app/models/all-MiniLM-L6-v2" \
    RETRIEVER_K="3" \
    STREAMLIT_SERVER_PORT="8501" \
    STREAMLIT_SERVER_ADDRESS="0.0.0.0" \
    STREAMLIT_SERVER_HEADLESS="true" \
    STREAMLIT_BROWSER_GATHER_USAGE_STATS="false" \
    PYTHONUNBUFFERED="1"

CMD ["streamlit", "run", "main.py"]

0개의 댓글