anilegin commited on
Commit
ecdcbd3
·
verified ·
1 Parent(s): 362d781

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -8
Dockerfile CHANGED
@@ -1,8 +1,7 @@
1
- # Use stable Bullseye to avoid library issues
2
  FROM python:3.9-slim-bullseye
3
 
4
  # 1. Install System Dependencies & C++ Compiler
5
- # Added 'build-essential' to fix the g++ error for insightface
6
  RUN apt-get update && apt-get install -y \
7
  build-essential \
8
  libgl1-mesa-glx \
@@ -12,7 +11,7 @@ RUN apt-get update && apt-get install -y \
12
  libxrender-dev \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
- # 2. Setup Non-Root User (Required for HF Spaces)
16
  RUN useradd -m -u 1000 user
17
  USER user
18
  ENV PATH="/home/user/.local/bin:$PATH"
@@ -21,15 +20,18 @@ ENV PATH="/home/user/.local/bin:$PATH"
21
  WORKDIR /app
22
  COPY --chown=user requirements.txt requirements.txt
23
 
24
- # Install dependencies
25
- # We upgrade pip first to ensure we get binary wheels if available
 
26
  RUN pip install --no-cache-dir --upgrade pip && \
27
- pip install --no-cache-dir -r requirements.txt
 
 
28
 
29
- # 4. Copy Code & Create InsightFace Directory
30
  COPY --chown=user . .
31
  RUN mkdir -p /home/user/.insightface && chmod 777 /home/user/.insightface
32
 
33
- # 5. Run Server
34
  EXPOSE 7860
35
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use stable Bullseye
2
  FROM python:3.9-slim-bullseye
3
 
4
  # 1. Install System Dependencies & C++ Compiler
 
5
  RUN apt-get update && apt-get install -y \
6
  build-essential \
7
  libgl1-mesa-glx \
 
11
  libxrender-dev \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
+ # 2. Setup User
15
  RUN useradd -m -u 1000 user
16
  USER user
17
  ENV PATH="/home/user/.local/bin:$PATH"
 
20
  WORKDIR /app
21
  COPY --chown=user requirements.txt requirements.txt
22
 
23
+ # 4. Install Dependencies & Fix Conflicts
24
+ # We install requirements, then FORCE UNINSTALL any standard OpenCV that MediaPipe might have pulled in.
25
+ # Then we reinstall headless to be sure.
26
  RUN pip install --no-cache-dir --upgrade pip && \
27
+ pip install --no-cache-dir -r requirements.txt && \
28
+ pip uninstall -y opencv-python opencv-contrib-python && \
29
+ pip install opencv-python-headless
30
 
31
+ # 5. Copy Code & Setup Directories
32
  COPY --chown=user . .
33
  RUN mkdir -p /home/user/.insightface && chmod 777 /home/user/.insightface
34
 
35
+ # 6. Run
36
  EXPOSE 7860
37
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]