Spaces:
No application file
No application file
File size: 911 Bytes
4add4a8 | 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 29 30 31 32 | # Use official Python runtime as a parent image
FROM python:3.9-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Hugging Face Spaces REQUIRE processes to run as a non-root user (uid 1000)
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Set working directory in the container
WORKDIR /home/user/app
# Copy requirements file first to leverage Docker cache
COPY --chown=user requirements.txt .
# Install dependencies statically
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code
COPY --chown=user . /home/user/app
# Expose port that FastAPI runs on internally (HF uses 7860)
EXPOSE 7860
# Start Uvicorn process binding to 0.0.0.0 and dynamically port 7860
CMD uvicorn backend.main:app --host 0.0.0.0 --port 7860
|