Spaces:
Sleeping
Sleeping
# Use an official Python runtime as the base image | |
FROM python:3.9-slim | |
# Set working directory | |
WORKDIR /app | |
# Install system dependencies (e.g., for FAISS) | |
RUN apt-get update && apt-get install -y \ | |
libgomp1 \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Copy requirements file | |
COPY requirements.txt . | |
# Install Python dependencies | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy the application code | |
COPY main.py . | |
# Create a non-root user and set permissions | |
RUN useradd -m -u 1000 appuser \ | |
&& mkdir -p /app/.cache \ | |
&& chown -R appuser:appuser /app | |
# Switch to the non-root user | |
USER appuser | |
# Expose the port (Hugging Face Spaces expects 7860) | |
EXPOSE 7860 | |
# Command to run the FastAPI app with uvicorn | |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] |