priyanshu23456 commited on
Commit
642fa09
·
verified ·
1 Parent(s): c8f90ae

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -24
Dockerfile CHANGED
@@ -1,43 +1,43 @@
1
  # Base image
2
  FROM python:3.10-slim
3
 
4
- # Set env to avoid interactive prompts and ensure models cache to /tmp
5
  ENV HF_HOME=/tmp \
6
  XDG_CACHE_HOME=/tmp \
7
- PYTHONUNBUFFERED=1
 
 
8
 
9
- # Install system dependencies
10
  RUN apt-get update && apt-get install -y --no-install-recommends \
11
- poppler-utils \
12
- tesseract-ocr \
13
- libglib2.0-0 \
14
- libsm6 \
15
- libxext6 \
16
- libxrender-dev \
17
  build-essential \
18
- libpoppler-dev \
19
- libtesseract-dev \
20
- libblas-dev \
21
- liblapack-dev \
22
- gfortran \
23
- && apt-get clean \
24
- && rm -rf /var/lib/apt/lists/*
25
 
26
  # Set working directory
27
  WORKDIR /app
28
 
29
- # Copy requirements and install
30
  COPY requirements.txt .
31
- RUN pip install --no-cache-dir -r requirements.txt
32
 
33
- # Copy app files
34
- COPY . .
 
35
 
36
- # Create upload directory and give full write permissions
 
 
 
37
  RUN mkdir -p /tmp/uploads && chmod 777 /tmp/uploads
38
 
39
- # Expose port (for local or HF Spaces)
40
  EXPOSE 7860
41
 
42
- # Start the Flask app
43
- CMD ["python", "app.py"]
 
 
 
 
 
1
  # Base image
2
  FROM python:3.10-slim
3
 
4
+ # Set environment variables
5
  ENV HF_HOME=/tmp \
6
  XDG_CACHE_HOME=/tmp \
7
+ PYTHONUNBUFFERED=1 \
8
+ TOKENIZERS_PARALLELISM=false \
9
+ TRANSFORMERS_CACHE=/tmp
10
 
11
+ # Install minimal system dependencies
12
  RUN apt-get update && apt-get install -y --no-install-recommends \
13
+ python3-dev \
 
 
 
 
 
14
  build-essential \
15
+ libopenblas-dev \
16
+ && apt-get clean \
17
+ && rm -rf /var/lib/apt/lists/*
 
 
 
 
18
 
19
  # Set working directory
20
  WORKDIR /app
21
 
22
+ # Copy requirements
23
  COPY requirements.txt .
 
24
 
25
+ # Install Python dependencies
26
+ RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
27
+ pip install --no-cache-dir -r requirements.txt
28
 
29
+ # Copy application files
30
+ COPY app.py .
31
+
32
+ # Create upload directory
33
  RUN mkdir -p /tmp/uploads && chmod 777 /tmp/uploads
34
 
35
+ # Expose port
36
  EXPOSE 7860
37
 
38
+ # Health check
39
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
40
+ CMD python -c "import requests; requests.get('http://localhost:7860/')" || exit 1
41
+
42
+ # Start application
43
+ CMD ["python", "app.py"]