mike23415 commited on
Commit
ad6cdd2
·
verified ·
1 Parent(s): 8812332

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +31 -10
Dockerfile CHANGED
@@ -1,37 +1,58 @@
 
1
  FROM python:3.9-slim
2
 
3
- # Install system dependencies including Tesseract
 
 
 
 
 
4
  RUN apt-get update && apt-get install -y \
5
  tesseract-ocr \
6
  tesseract-ocr-eng \
7
  tesseract-ocr-fra \
8
  tesseract-ocr-deu \
9
  tesseract-ocr-spa \
 
 
 
 
 
 
10
  libgl1-mesa-glx \
11
  libglib2.0-0 \
12
  libsm6 \
13
  libxext6 \
14
  libxrender-dev \
15
  libgomp1 \
16
- wget \
 
17
  && rm -rf /var/lib/apt/lists/*
18
 
19
  # Set working directory
20
  WORKDIR /app
21
 
22
- # Copy requirements and install Python packages
23
  COPY requirements.txt .
24
- RUN pip install --no-cache-dir -r requirements.txt
25
 
26
- # Copy application code
 
 
 
 
27
  COPY . .
28
 
29
- # Expose port
 
 
 
 
 
30
  EXPOSE 7860
31
 
32
- # Set environment variables for Hugging Face Spaces
33
- ENV GRADIO_SERVER_NAME="0.0.0.0"
34
- ENV GRADIO_SERVER_PORT=7860
35
 
36
- # Run the application
37
  CMD ["python", "app.py"]
 
1
+ # Use Python 3.9 slim image for better compatibility with Hugging Face
2
  FROM python:3.9-slim
3
 
4
+ # Set environment variables
5
+ ENV PYTHONUNBUFFERED=1
6
+ ENV DEBIAN_FRONTEND=noninteractive
7
+ ENV PORT=7860
8
+
9
+ # Install system dependencies required for OCR
10
  RUN apt-get update && apt-get install -y \
11
  tesseract-ocr \
12
  tesseract-ocr-eng \
13
  tesseract-ocr-fra \
14
  tesseract-ocr-deu \
15
  tesseract-ocr-spa \
16
+ tesseract-ocr-ita \
17
+ tesseract-ocr-por \
18
+ tesseract-ocr-rus \
19
+ tesseract-ocr-ara \
20
+ tesseract-ocr-hin \
21
+ libtesseract-dev \
22
  libgl1-mesa-glx \
23
  libglib2.0-0 \
24
  libsm6 \
25
  libxext6 \
26
  libxrender-dev \
27
  libgomp1 \
28
+ libgcc-s1 \
29
+ && apt-get clean \
30
  && rm -rf /var/lib/apt/lists/*
31
 
32
  # Set working directory
33
  WORKDIR /app
34
 
35
+ # Copy requirements first for better Docker layer caching
36
  COPY requirements.txt .
 
37
 
38
+ # Install Python dependencies
39
+ RUN pip install --no-cache-dir --upgrade pip && \
40
+ pip install --no-cache-dir -r requirements.txt
41
+
42
+ # Copy the application code
43
  COPY . .
44
 
45
+ # Create a non-root user for security (Hugging Face best practice)
46
+ RUN useradd -m -u 1000 user
47
+ RUN chown -R user:user /app
48
+ USER user
49
+
50
+ # Expose the port that Hugging Face expects
51
  EXPOSE 7860
52
 
53
+ # Health check
54
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
55
+ CMD curl -f http://localhost:7860/health || exit 1
56
 
57
+ # Start the application
58
  CMD ["python", "app.py"]