IntrusionModel / Dockerfile
pranitchilbule221's picture
Rename Dockerfile.fastapi to Dockerfile
5ea26be verified
raw
history blame contribute delete
955 Bytes
# Use a slim Python image for the production environment
FROM python:3.9-slim
# Set working directory
WORKDIR /app
# Install system dependencies for OpenCV and YOLO
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
libsm6 \
libxext6 \
libgl1 \
&& rm -rf /var/lib/apt/lists/*
# Copy dependency list
COPY requirements.txt .
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the YOLO model and application code
COPY yolo11n.pt .
COPY fastapi_app.py .
# Create a non-root user for security (required by Hugging Face)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
COPY --chown=user . $HOME/app
# Hugging Face uses port 7860 by default
EXPOSE 7860
# Command to run the FastAPI app with Uvicorn
CMD ["uvicorn", "fastapi_app:app", "--host", "0.0.0.0", "--port", "7860"]