qa_api / Dockerfile
rabiyulfahim's picture
Update Dockerfile
17fe721 verified
# Use lightweight Python image
FROM python:3.10-slim
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
# Copy requirements and install
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Pre-download model into app folder (readable by the app process)
RUN mkdir -p /tmp/huggingface
RUN python -c "from transformers import AutoTokenizer, AutoModelForCausalLM; \
model_id='deepseek-ai/DeepSeek-R1'; \
AutoTokenizer.from_pretrained(model_id, cache_dir='/tmp/huggingface'); \
AutoModelForCausalLM.from_pretrained(model_id, cache_dir='/tmp/huggingface')"
# Hugging Face cache directory
ENV HF_HOME=/tmp/huggingface
ENV TRANSFORMERS_CACHE=/tmp/huggingface
# Expose FastAPI port
EXPOSE 7860
# Command to run FastAPI app
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]