tommulder commited on
Commit
e6ea720
·
1 Parent(s): ee232e9

Fix Dockerfile for Debian Trixie compatibility

Browse files

- Replace libgl1-mesa-glx with libgl1-mesa-dri (package name changed in Debian Trixie)
- Add comprehensive OpenCV dependencies for proper image processing
- Implement proper user permissions as recommended by HF Spaces docs
- Install system dependencies as root before switching to user
- Add proper file ownership with --chown=user flags

Files changed (2) hide show
  1. Dockerfile +31 -7
  2. README.md +1 -1
Dockerfile CHANGED
@@ -1,26 +1,50 @@
1
  FROM python:3.11-slim
2
 
3
- # Set working directory
4
- WORKDIR /app
5
-
6
- # Install system dependencies
7
  RUN apt-get update && apt-get install -y \
8
- libgl1-mesa-glx \
9
  libglib2.0-0 \
10
  libsm6 \
11
  libxext6 \
12
  libxrender-dev \
13
  libgomp1 \
 
 
 
 
 
 
 
 
 
 
 
14
  && rm -rf /var/lib/apt/lists/*
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  # Copy requirements first for better caching
17
- COPY requirements.txt .
18
 
19
  # Install Python dependencies
20
  RUN pip install --no-cache-dir -r requirements.txt
21
 
22
  # Copy application code
23
- COPY . .
24
 
25
  # Expose port
26
  EXPOSE 7860
 
1
  FROM python:3.11-slim
2
 
3
+ # Install system dependencies as root first
 
 
 
4
  RUN apt-get update && apt-get install -y \
5
+ libgl1-mesa-dri \
6
  libglib2.0-0 \
7
  libsm6 \
8
  libxext6 \
9
  libxrender-dev \
10
  libgomp1 \
11
+ libgthread-2.0-0 \
12
+ libgtk-3-0 \
13
+ libgdk-pixbuf2.0-0 \
14
+ libxss1 \
15
+ libgconf-2-4 \
16
+ libnss3 \
17
+ libxrandr2 \
18
+ libasound2 \
19
+ libpangocairo-1.0-0 \
20
+ libatk1.0-0 \
21
+ libcairo-gobject2 \
22
  && rm -rf /var/lib/apt/lists/*
23
 
24
+ # Set up a new user named "user" with user ID 1000
25
+ RUN useradd -m -u 1000 user
26
+
27
+ # Switch to the "user" user
28
+ USER user
29
+
30
+ # Set home to the user's home directory
31
+ ENV HOME=/home/user \
32
+ PATH=/home/user/.local/bin:$PATH
33
+
34
+ # Set the working directory to the user's home directory
35
+ WORKDIR $HOME/app
36
+
37
+ # Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
38
+ RUN pip install --no-cache-dir --upgrade pip
39
+
40
  # Copy requirements first for better caching
41
+ COPY --chown=user requirements.txt .
42
 
43
  # Install Python dependencies
44
  RUN pip install --no-cache-dir -r requirements.txt
45
 
46
  # Copy application code
47
+ COPY --chown=user . .
48
 
49
  # Expose port
50
  EXPOSE 7860
README.md CHANGED
@@ -6,7 +6,7 @@ colorTo: "purple"
6
  sdk: docker
7
  app_port: 7860
8
  pinned: false
9
- license: "private"
10
  short_description: "Ultralytics YOLO-E for European identity document detection with quality assessment"
11
  ---
12
 
 
6
  sdk: docker
7
  app_port: 7860
8
  pinned: false
9
+ license: "other"
10
  short_description: "Ultralytics YOLO-E for European identity document detection with quality assessment"
11
  ---
12