davidic / Dockerfile
babaTEEpe's picture
Upload 3 files
3685254 verified
raw
history blame contribute delete
721 Bytes
FROM python:3.10-slim
WORKDIR /app
# Copy requirements first to cache dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Pre-download the model during build so it doesn't download on every startup
# We use a small python script to trigger the download
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')"
# Copy application code
COPY app.py .
# Create a user to avoid running as root (good practice for HF Spaces)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]