triflix commited on
Commit
283bdfb
·
verified ·
1 Parent(s): 594bd58

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +30 -10
Dockerfile CHANGED
@@ -1,21 +1,41 @@
 
 
 
1
  FROM python:3.10-slim
2
 
3
- RUN apt-get update && apt-get install -y \
4
- libgomp1 \
5
- libstdc++6 \
6
- poppler-utils \
 
 
 
 
7
  libglib2.0-0 \
8
  libsm6 \
9
  libxrender1 \
10
  libxext6 \
11
- && apt-get clean
 
 
12
 
13
- COPY requirements.txt /app/requirements.txt
14
- RUN pip install --no-cache-dir -r /app/requirements.txt
15
 
 
16
  COPY app.py /app/app.py
17
- WORKDIR /app
18
 
19
- EXPOSE 7860
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
+ # Dockerfile
2
+ # Minimal, explicit CPU PaddlePaddle + PaddleOCR install for HuggingFace Space.
3
+ # Installs packages via pip (no requirements.txt), uses non-root runtime user.
4
  FROM python:3.10-slim
5
 
6
+ # Create a non-root user for least-privilege execution
7
+ ARG USERNAME=appuser
8
+ RUN groupadd -r ${USERNAME} && useradd -r -g ${USERNAME} ${USERNAME}
9
+
10
+ # System dependencies required by Pillow / PyMuPDF and common Linux libs
11
+ RUN apt-get update && apt-get install -y --no-install-recommends \
12
+ build-essential \
13
+ libgl1 \
14
  libglib2.0-0 \
15
  libsm6 \
16
  libxrender1 \
17
  libxext6 \
18
+ git \
19
+ ca-certificates \
20
+ && rm -rf /var/lib/apt/lists/*
21
 
22
+ WORKDIR /app
 
23
 
24
+ # Copy application code (expecting app.py at build time)
25
  COPY app.py /app/app.py
 
26
 
27
+ # Install Python dependencies via pip directly inside Dockerfile (no requirements.txt)
28
+ # The two lines below match user's requested commands for paddlepaddle and paddleocr (CPU).
29
+ RUN pip install --upgrade pip setuptools wheel \
30
+ && pip install fastapi uvicorn python-multipart pydantic Pillow PyMuPDF \
31
+ && pip install paddlepaddle==3.0.0 \
32
+ && python -m pip install paddleocr
33
+
34
+ # Expose port used by uvicorn
35
+ EXPOSE 8000
36
+
37
+ # Switch to non-root user
38
+ USER ${USERNAME}
39
 
40
+ # Entrypoint - run uvicorn for the FastAPI app
41
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]