File size: 791 Bytes
bf2fb2a 1bd80e5 0c78e88 1bd80e5 0c78e88 1bd80e5 0c78e88 1bd80e5 0c78e88 1bd80e5 0c78e88 1bd80e5 0c78e88 1bd80e5 0c78e88 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | FROM python:3.11-slim
# Create a non-root user with UID 1000 as required by HF Spaces
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONPATH=/app \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
WORKDIR /app
# Install Python dependencies
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
# Copy all application files into the container
COPY --chown=user . .
# Expose the mandatory Hugging Face port
EXPOSE 7860
# Run FastAPI directly in the foreground
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] |