# Use an official Python runtime as a parent image | |
FROM python:3.11-slim | |
# Create a non-root user with home directory | |
RUN useradd -m -u 1000 appuser | |
USER appuser | |
# Add local user bin directory to PATH | |
ENV PATH="/home/appuser/.local/bin:$PATH" | |
# Set working directory inside the container | |
WORKDIR /app | |
# Copy requirements and install dependencies | |
COPY --chown=appuser:appuser requirements.txt requirements.txt | |
RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
# Copy all the app files | |
COPY --chown=appuser:appuser . /app | |
# Expose the port that HF Spaces requires | |
EXPOSE 7860 | |
# Command to run the app with uvicorn on port 7860, listening on all interfaces | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |