Devam0 commited on
Commit
da02aa2
·
1 Parent(s): aa57537

Aggressive OpenCV fix - install all Mesa libraries and force headless only

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -6
Dockerfile CHANGED
@@ -1,7 +1,7 @@
1
  # Base image - using bullseye for better compatibility
2
  FROM python:3.9-bullseye
3
 
4
- # Install system dependencies first
5
  RUN apt-get update && apt-get install -y \
6
  libglib2.0-0 \
7
  libsm6 \
@@ -9,6 +9,9 @@ RUN apt-get update && apt-get install -y \
9
  libxrender1 \
10
  libgomp1 \
11
  libgl1-mesa-glx \
 
 
 
12
  libgtk-3-0 \
13
  libavcodec58 \
14
  libavformat58 \
@@ -21,6 +24,8 @@ RUN apt-get update && apt-get install -y \
21
  libtiff5 \
22
  libatlas-base-dev \
23
  gfortran \
 
 
24
  && rm -rf /var/lib/apt/lists/*
25
 
26
  # Set working directory
@@ -29,13 +34,13 @@ WORKDIR /app
29
  # Copy requirements and install Python packages
30
  COPY requirements.txt .
31
 
32
- # Install OpenCV headless first and remove any conflicting packages
33
- RUN pip install --no-cache-dir opencv-python-headless==4.8.1.78 && \
34
- pip uninstall -y opencv-python opencv-contrib-python || true
 
35
 
36
  # Install other dependencies
37
- RUN pip install --no-cache-dir --upgrade pip && \
38
- pip install --no-cache-dir -r requirements.txt
39
 
40
  # Copy project files
41
  COPY . .
 
1
  # Base image - using bullseye for better compatibility
2
  FROM python:3.9-bullseye
3
 
4
+ # Install ALL system dependencies for OpenCV
5
  RUN apt-get update && apt-get install -y \
6
  libglib2.0-0 \
7
  libsm6 \
 
9
  libxrender1 \
10
  libgomp1 \
11
  libgl1-mesa-glx \
12
+ libgl1-mesa-dri \
13
+ libgl1-mesa-swx11 \
14
+ libglu1-mesa \
15
  libgtk-3-0 \
16
  libavcodec58 \
17
  libavformat58 \
 
24
  libtiff5 \
25
  libatlas-base-dev \
26
  gfortran \
27
+ mesa-utils \
28
+ xvfb \
29
  && rm -rf /var/lib/apt/lists/*
30
 
31
  # Set working directory
 
34
  # Copy requirements and install Python packages
35
  COPY requirements.txt .
36
 
37
+ # Force remove any existing OpenCV packages and install only headless
38
+ RUN pip install --no-cache-dir --upgrade pip && \
39
+ pip uninstall -y opencv-python opencv-contrib-python opencv-python-headless || true && \
40
+ pip install --no-cache-dir opencv-python-headless==4.8.1.78
41
 
42
  # Install other dependencies
43
+ RUN pip install --no-cache-dir -r requirements.txt
 
44
 
45
  # Copy project files
46
  COPY . .