File size: 1,519 Bytes
aa57537 37069da da02aa2 355774b c0e2fd2 aa57537 da02aa2 aa57537 da02aa2 355774b 37069da 8aeddce aa57537 355774b aa57537 da02aa2 aa57537 da02aa2 37069da 355774b 37069da | 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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # Base image - using bullseye for better compatibility
FROM python:3.9-bullseye
# Install ALL system dependencies for OpenCV
RUN apt-get update && apt-get install -y \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender1 \
libgomp1 \
libgl1-mesa-glx \
libgl1-mesa-dri \
libglu1-mesa \
libgtk-3-0 \
libavcodec58 \
libavformat58 \
libswscale5 \
libv4l-0 \
libxvidcore4 \
libx264-160 \
libjpeg62-turbo \
libpng16-16 \
libtiff5 \
libatlas-base-dev \
gfortran \
mesa-utils \
xvfb \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Create writable directories for Hugging Face cache
RUN mkdir -p /app/.cache /app/.config && \
chmod 777 /app/.cache /app/.config
# Set environment variables for Hugging Face
ENV HF_HOME=/app/.cache
ENV TRANSFORMERS_CACHE=/app/.cache
ENV YOLO_CONFIG_DIR=/app/.config
# Copy requirements and install Python packages
COPY requirements.txt .
# Force remove any existing OpenCV packages and install only headless
RUN pip install --no-cache-dir --upgrade pip && \
pip uninstall -y opencv-python opencv-contrib-python opencv-python-headless || true && \
pip install --no-cache-dir opencv-python-headless==4.8.1.78
# Install other dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy project files
COPY . .
# Expose Hugging Face Space port
EXPOSE 7860
# Start FastAPI server
CMD ["uvicorn", "inference_server:app", "--host", "0.0.0.0", "--port", "7860"]
|