# Use an appropriate base image | |
FROM python:3.9 | |
# Create a user with specific permissions | |
RUN useradd -m -u 1000 user | |
# Set working directory | |
WORKDIR /app | |
# Copy requirements and install dependencies | |
COPY --chown=user ./requirements.txt requirements.txt | |
RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
# Copy all project files | |
COPY --chown=user . /app | |
# Switch to non-root user | |
USER user | |
# Set environment variables | |
ENV HOME=/home/user \ | |
PATH=/home/user/.local/bin:$PATH | |
# Expose the default Hugging Face Spaces port | |
EXPOSE 7860 | |
# Default command to run the application | |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] |