File size: 875 Bytes
186ce20 0b7478a 186ce20 | 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 33 34 35 36 | # Use an official Python runtime as a parent image
FROM python:3.12-slim
# Set the working directory in the container
WORKDIR /app
# Install system dependencies (needed for OpenCV, Pillow, etc.)
RUN apt-get update && apt-get install -y \
build-essential \
libgl1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Create a non-privileged user to run the app
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# Copy the requirements file into the container
COPY --chown=user requirements.txt .
# Install dependencies
RUN pip install --no-cache-dir --user -r requirements.txt
# Copy the rest of the application code
COPY --chown=user . .
# Expose the port Hugging Face expects
EXPOSE 7860
# Command to run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|