szoya commited on
Commit
45a5ef3
·
verified ·
1 Parent(s): 99a02e0

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -7
Dockerfile CHANGED
@@ -1,22 +1,33 @@
 
1
  FROM python:3.9-slim
2
 
3
  WORKDIR /app
4
 
5
- # Install system dependencies
6
- # ADDED: libgomp1 (Fixes the crash)
7
  RUN apt-get update && apt-get install -y \
8
  libgl1 \
9
  libglib2.0-0 \
10
  libgomp1 \
 
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
- COPY requirements.txt .
14
- RUN pip install --no-cache-dir -r requirements.txt
15
 
16
- # Pre-download models
17
- # UPDATED: use_textline_orientation=False (Fixes the warning)
18
- RUN python -c "from paddleocr import PaddleOCR; PaddleOCR(lang='en', use_textline_orientation=False)"
19
 
 
 
 
 
 
 
 
 
 
20
  COPY main.py .
21
 
 
22
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Start with a clean slate
2
  FROM python:3.9-slim
3
 
4
  WORKDIR /app
5
 
6
+ # 1. Install System Deps
 
7
  RUN apt-get update && apt-get install -y \
8
  libgl1 \
9
  libglib2.0-0 \
10
  libgomp1 \
11
+ git \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
+ # 2. Upgrade Pip & Setuptools (Crucial for avoiding build errors)
15
+ RUN pip install --no-cache-dir --upgrade pip setuptools==69.5.1 wheel
16
 
17
+ # 3. Install PaddlePaddle FIRST (The Heavyweight)
18
+ # Installing this alone ensures it gets full resources without conflict
19
+ RUN pip install --no-cache-dir paddlepaddle==2.6.1 -i https://mirror.baidu.com/pypi/simple
20
 
21
+ # 4. Install PaddleOCR & Deps
22
+ # We fix the version to 2.7.3 which is known stable with Paddle 2.6.1
23
+ RUN pip install --no-cache-dir "paddleocr>=2.7.0" numpy==1.26.4 opencv-python-headless pillow fastapi uvicorn python-multipart
24
+
25
+ # 5. Pre-download Models (Cache them in the image)
26
+ # use_angle_cls=False avoids the classifier model download/loading
27
+ RUN python -c "from paddleocr import PaddleOCR; PaddleOCR(lang='en', use_angle_cls=False)"
28
+
29
+ # 6. Copy App Code
30
  COPY main.py .
31
 
32
+ # 7. Start
33
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]