itemaz commited on
Commit
25a2cbb
·
verified ·
1 Parent(s): 188038a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -13
Dockerfile CHANGED
@@ -1,7 +1,6 @@
1
  FROM python:3.11-slim
2
 
3
- # 1. Install system dependencies
4
- # libgomp1 is critical for PaddlePaddle/OpenCV execution
5
  RUN apt-get update && apt-get install -y \
6
  default-jre \
7
  libgl1 \
@@ -14,30 +13,29 @@ RUN apt-get update && apt-get install -y \
14
 
15
  WORKDIR /app
16
 
17
- # 2. Set Environment Variables for Model Caching
18
- # This ensures models are saved in /tmp (writable in most cloud environments)
19
  ENV HOME=/tmp
20
  ENV HF_HOME=/tmp/.cache
21
  ENV PADDLE_HOME=/tmp/.paddle
22
  ENV TRANSFORMERS_CACHE=/tmp/.cache
23
  ENV XDG_CACHE_HOME=/tmp/.cache
24
 
25
- # 3. Install Python dependencies
26
- # We install paddlepaddle-tiny to keep the image size smaller
27
  COPY requirements.txt .
28
- RUN pip install --no-cache-dir -r requirements.txt
29
- RUN pip install --no-cache-dir gunicorn whitenoise paddlepaddle-tiny paddleocr
30
 
31
- # 4. Copy project files
 
 
 
32
  COPY . .
33
 
34
- # 5. Django static files collection
35
  RUN python manage.py collectstatic --noinput
36
 
37
- # 6. Expose port (7860 is default for Hugging Face Spaces)
38
  ENV PORT=7860
39
  EXPOSE 7860
40
 
41
- # 7. Run the application
42
- # Increased timeout to 600s because models (OCR/BART) take time to load on first request
43
  CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--timeout", "600", "--workers", "1", "litrix.wsgi:application"]
 
1
  FROM python:3.11-slim
2
 
3
+ # 1. Install system dependencies (libgomp1 is critical for Paddle)
 
4
  RUN apt-get update && apt-get install -y \
5
  default-jre \
6
  libgl1 \
 
13
 
14
  WORKDIR /app
15
 
16
+ # 2. Set storage paths for models
 
17
  ENV HOME=/tmp
18
  ENV HF_HOME=/tmp/.cache
19
  ENV PADDLE_HOME=/tmp/.paddle
20
  ENV TRANSFORMERS_CACHE=/tmp/.cache
21
  ENV XDG_CACHE_HOME=/tmp/.cache
22
 
23
+ # 3. Upgrade pip and install core requirements
 
24
  COPY requirements.txt .
25
+ RUN pip install --no-cache-dir --upgrade pip && \
26
+ pip install --no-cache-dir -r requirements.txt
27
 
28
+ # 4. Install PaddleOCR and standard Paddle (Tiny is outdated)
29
+ RUN pip install --no-cache-dir paddlepaddle paddleocr gunicorn whitenoise
30
+
31
+ # 5. Copy project files
32
  COPY . .
33
 
34
+ # 6. Django static files collection
35
  RUN python manage.py collectstatic --noinput
36
 
37
+ # 7. Server configuration
38
  ENV PORT=7860
39
  EXPOSE 7860
40
 
 
 
41
  CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--timeout", "600", "--workers", "1", "litrix.wsgi:application"]