tourism-api / Dockerfile
phamluan's picture
Deploy RAG Tourism API
54c816a verified
Raw
History Blame Contribute Delete
1.18 kB
# API container — chạy được cả local lẫn Hugging Face Space (Docker SDK).
# HF Space yêu cầu app lắng nghe cổng 7860 (hoặc $PORT).
FROM python:3.11-slim
WORKDIR /app
# System deps: build tools + ffmpeg (PhoWhisper STT) + git (tải model từ HF)
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
ffmpeg \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code (app/ bao gồm cả chroma_db*/ đã build sẵn nếu có)
COPY app/ ./app/
COPY kg_data_import.py .
COPY validate_kg.py .
COPY datasets/ ./datasets/
# HF Space chạy user không phải root — trỏ mọi cache về /tmp (ghi được)
ENV HF_HOME=/tmp/hf \
TRANSFORMERS_CACHE=/tmp/hf \
SENTENCE_TRANSFORMERS_HOME=/tmp/hf \
XDG_CACHE_HOME=/tmp/cache
RUN mkdir -p /tmp/hf /tmp/cache && chmod -R 777 /tmp/hf /tmp/cache /app
# Cổng: 7860 cho HF Space, override bằng $PORT nếu platform khác
EXPOSE 7860
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-7860}"]