brain-stroke-fastapi / Dockerfile
harshpatel080503's picture
Upload Dockerfile
0b7478a verified
raw
history blame contribute delete
875 Bytes
# 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"]