anujakkulkarni commited on
Commit
8a933b1
·
verified ·
1 Parent(s): c9627e2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -7
Dockerfile CHANGED
@@ -1,21 +1,41 @@
 
1
  FROM python:3.10-slim
2
 
3
- WORKDIR /app
 
 
4
 
5
- # Install system dependencies
6
- RUN apt-get update && apt-get install -y \
 
7
  build-essential \
 
 
 
 
 
 
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
- # Copy requirements and install
 
 
 
11
  COPY requirements.txt .
12
- RUN pip install --no-cache-dir -r requirements.txt
 
 
 
13
 
14
  # Copy application code
15
  COPY app.py .
16
 
17
- # Expose port
18
  EXPOSE 7860
19
 
 
 
 
 
20
  # Run the application
21
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use an official Python runtime as a parent image
2
  FROM python:3.10-slim
3
 
4
+ # Set environment variables
5
+ ENV PYTHONUNBUFFERED=1
6
+ ENV DEBIAN_FRONTEND=noninteractive
7
 
8
+ # Install system dependencies for PyMuPDF and Pillow
9
+ RUN apt-get update && \
10
+ apt-get install -y --no-install-recommends \
11
  build-essential \
12
+ libgl1 \
13
+ libglib2.0-0 \
14
+ libsm6 \
15
+ libxext6 \
16
+ libxrender-dev \
17
+ libgomp1 \
18
  && rm -rf /var/lib/apt/lists/*
19
 
20
+ # Set working directory
21
+ WORKDIR /code
22
+
23
+ # Copy requirements first for Docker layer caching
24
  COPY requirements.txt .
25
+
26
+ # Install Python dependencies
27
+ RUN pip install --upgrade pip && \
28
+ pip install --no-cache-dir -r requirements.txt
29
 
30
  # Copy application code
31
  COPY app.py .
32
 
33
+ # Expose port 7860 (required by Hugging Face Spaces)
34
  EXPOSE 7860
35
 
36
+ # Health check (optional but recommended)
37
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
38
+ CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 1
39
+
40
  # Run the application
41
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--timeout-keep-alive", "600"]