szoya commited on
Commit
ac7098a
·
verified ·
1 Parent(s): dd0367a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -17
Dockerfile CHANGED
@@ -1,9 +1,9 @@
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 \
@@ -11,23 +11,30 @@ RUN apt-get update && apt-get install -y \
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"]
 
1
+ # Start with a clean Python 3.9 Image
2
  FROM python:3.9-slim
3
 
4
  WORKDIR /app
5
 
6
+ # 1. Install System Dependencies
7
  RUN apt-get update && apt-get install -y \
8
  libgl1 \
9
  libglib2.0-0 \
 
11
  git \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
+ # 2. Upgrade Pip to handle large downloads better
15
+ RUN pip install --no-cache-dir --upgrade pip setuptools wheel
16
+
17
+ # 3. Install PaddlePaddle (CPU)
18
+ # We use standard PyPI with a long timeout to prevent connection drops
19
+ RUN pip install --no-cache-dir paddlepaddle==2.6.1 --default-timeout=100
20
+
21
+ # 4. Install PaddleOCR & API Dependencies
22
+ # Pinned versions to ensure 100% compatibility
23
+ RUN pip install --no-cache-dir \
24
+ "paddleocr==2.7.3" \
25
+ "numpy<2.0.0" \
26
+ opencv-python-headless \
27
+ pillow \
28
+ fastapi \
29
+ uvicorn \
30
+ python-multipart
31
+
32
+ # 5. Pre-download the AI Models (Cache them inside the image)
33
+ # use_angle_cls=False avoids downloading the classifier model
34
  RUN python -c "from paddleocr import PaddleOCR; PaddleOCR(lang='en', use_angle_cls=False)"
35
 
36
+ # 6. Copy Application Code
37
  COPY main.py .
38
 
39
+ # 7. Start the API
40
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]