Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +24 -17
Dockerfile
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
-
# Start with a clean
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
-
# 1. Install System
|
| 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
|
| 15 |
-
RUN pip install --no-cache-dir --upgrade pip setuptools
|
| 16 |
-
|
| 17 |
-
# 3. Install PaddlePaddle
|
| 18 |
-
#
|
| 19 |
-
RUN pip install --no-cache-dir paddlepaddle==2.6.1 -
|
| 20 |
-
|
| 21 |
-
# 4. Install PaddleOCR &
|
| 22 |
-
#
|
| 23 |
-
RUN pip install --no-cache-dir
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
RUN python -c "from paddleocr import PaddleOCR; PaddleOCR(lang='en', use_angle_cls=False)"
|
| 28 |
|
| 29 |
-
# 6. Copy
|
| 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"]
|