Spaces:
Runtime error
Runtime error
File size: 1,236 Bytes
42a8606 02ce1c3 57759fd e7a29ac 42a8606 0004ce1 e7a29ac 42a8606 978697b 1546f93 e7a29ac 1546f93 0004ce1 7d66f0d 0004ce1 42a8606 57759fd 42a8606 57759fd 42a8606 57759fd e7a29ac 42a8606 57759fd 1546f93 a768cc8 42a8606 355a53f |
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 37 38 39 40 41 42 43 44 45 |
# Use Python 3.10-slim as base image
FROM python:3.10-slim
# Install system dependencies for OpenCV, FFmpeg, and debugging
RUN apt-get update && apt-get install -y \
libgl1-mesa-glx \
libglib2.0-0 \
ffmpeg \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user and set up directories
RUN useradd -m -u 1000 appuser && \
mkdir -p /tmp/Ultralytics /snapshots /app && \
chown -R appuser:appuser /tmp/Ultralytics /snapshots /app && \
chmod -R 777 /tmp/Ultralytics /snapshots /app
# Set environment variables early
ENV YOLO_CONFIG_DIR=/tmp/Ultralytics
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
# Set working directory
WORKDIR /app
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Download YOLOv8n model weights if not present in project directory
RUN curl -L -o yolov8n.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt && \
chown appuser:appuser yolov8n.pt && \
chmod 644 yolov8n.pt
# Copy application code
COPY . .
# Switch to non-root user
USER appuser
# Expose port 8000 for FastAPI
EXPOSE 8000
# Run FastAPI app with uvicorn
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] |