text2sql-chatbot / Dockerfile
nilotpaldhar2004's picture
Update Dockerfile
2d93e30 verified
Raw
History Blame Contribute Delete
955 Bytes
# Use 3.11 to maintain compatibility with Torch 2.3.0
FROM python:3.11-slim
# 1. Install system dependencies for C++ builds (needed for sentencepiece)
USER root
RUN apt-get update && apt-get install -y \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# 2. Setup non-root user for Hugging Face
RUN useradd -m -u 1000 user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
HF_HOME=/home/user/.cache/huggingface
WORKDIR $HOME/app
# 3. Initialize cache directories
RUN mkdir -p $HF_HOME && chown -R user:user $HOME
USER user
# 4. Install Python requirements
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# 5. Copy application code
COPY --chown=user . .
# 6. Expose port 7860 for Hugging Face Spaces
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]