| | |
| | |
| | |
| | FROM python:3.11-slim-bookworm AS builder |
| |
|
| | WORKDIR /app |
| |
|
| | |
| | RUN apt-get update && \ |
| | apt-get install -y --no-install-recommends curl && \ |
| | rm -rf /var/lib/apt/lists/* |
| |
|
| | |
| | ENV PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cpu |
| |
|
| | |
| | RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu |
| |
|
| | |
| | COPY requirements.txt . |
| | RUN pip install --no-cache-dir -r requirements.txt |
| |
|
| | |
| | |
| | |
| | COPY pyproject.toml . |
| | COPY sage/ sage/ |
| | RUN pip install --no-cache-dir . --no-deps |
| |
|
| | |
| | ENV HF_HOME=/app/.cache/huggingface |
| |
|
| | |
| | RUN python -c "\ |
| | from sentence_transformers import SentenceTransformer; \ |
| | SentenceTransformer('intfloat/e5-small-v2')" |
| |
|
| | |
| | |
| | RUN python -c "\ |
| | from transformers import AutoConfig, AutoTokenizer; \ |
| | from huggingface_hub import hf_hub_download; \ |
| | config = AutoConfig.from_pretrained('vectara/hallucination_evaluation_model', trust_remote_code=True); \ |
| | AutoTokenizer.from_pretrained(config.foundation); \ |
| | AutoConfig.from_pretrained(config.foundation); \ |
| | hf_hub_download('vectara/hallucination_evaluation_model', 'model.safetensors')" |
| |
|
| |
|
| | |
| | |
| | |
| | FROM python:3.11-slim-bookworm AS runtime |
| |
|
| | WORKDIR /app |
| |
|
| | |
| | RUN apt-get update && \ |
| | apt-get install -y --no-install-recommends curl && \ |
| | rm -rf /var/lib/apt/lists/* |
| |
|
| | |
| | RUN useradd -m -u 1000 user |
| |
|
| | |
| | COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages |
| | COPY --from=builder /usr/local/bin /usr/local/bin |
| |
|
| | |
| | COPY --from=builder /app/sage /app/sage |
| |
|
| | |
| | COPY --from=builder /app/.cache /app/.cache |
| |
|
| | |
| | ENV HF_HOME=/app/.cache/huggingface |
| | ENV PYTHONUNBUFFERED=1 |
| |
|
| | |
| | RUN chown -R user:user /app |
| |
|
| | USER user |
| |
|
| | |
| | ENV PORT=7860 |
| | EXPOSE 7860 |
| |
|
| | |
| | HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \ |
| | CMD curl -sf http://localhost:${PORT:-7860}/health || exit 1 |
| |
|
| | CMD ["python", "-m", "sage.api.run", "--host", "0.0.0.0"] |
| |
|