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

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -12
Dockerfile CHANGED
@@ -1,29 +1,43 @@
1
  FROM python:3.11-slim
2
 
3
-
 
4
  RUN apt-get update && apt-get install -y \
5
- default-jre libgl1 libglx-mesa0 libglib2.0-0 gcc g++ \
6
- && rm -rf /var/lib/apt/lists/*
7
-
 
 
 
 
 
8
 
9
  WORKDIR /app
10
 
11
-
12
- # Важно: используем /data, если он есть, или /tmp
 
13
  ENV HF_HOME=/tmp/.cache
 
 
 
14
 
15
-
 
16
  COPY requirements.txt .
17
  RUN pip install --no-cache-dir -r requirements.txt
18
- RUN pip install gunicorn whitenoise
19
-
20
 
 
21
  COPY . .
22
- RUN python manage.py collectstatic --noinput
23
 
 
 
24
 
 
25
  ENV PORT=7860
26
  EXPOSE 7860
27
 
28
-
29
- 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
4
+ # libgomp1 is critical for PaddlePaddle/OpenCV execution
5
  RUN apt-get update && apt-get install -y \
6
+ default-jre \
7
+ libgl1 \
8
+ libglx-mesa0 \
9
+ libglib2.0-0 \
10
+ gcc \
11
+ g++ \
12
+ libgomp1 \
13
+ && rm -rf /var/lib/apt/lists/*
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"]