priyanshu23456 commited on
Commit
887b9c5
·
verified ·
1 Parent(s): 5b5c1fd

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -16
Dockerfile CHANGED
@@ -1,36 +1,39 @@
1
- # Use an official Python base image
2
- FROM python:3.11-slim
3
 
4
- # Set environment variables
5
- ENV PYTHONDONTWRITEBYTECODE=1
6
- ENV PYTHONUNBUFFERED=1
 
 
7
 
8
- # Set work directory
9
- WORKDIR /app
10
-
11
- # System dependencies
12
  RUN apt-get update && apt-get install -y \
13
  poppler-utils \
14
  tesseract-ocr \
15
- build-essential \
16
  libglib2.0-0 \
17
  libsm6 \
18
  libxext6 \
19
  libxrender-dev \
 
 
20
  && rm -rf /var/lib/apt/lists/*
21
 
22
- # Install Python dependencies
 
 
 
23
  COPY requirements.txt .
24
  RUN pip install --no-cache-dir -r requirements.txt
25
 
26
- # Create upload folder with write permissions
27
- RUN mkdir -p /app/uploads && chmod -R 777 /app/uploads
28
-
29
  # Copy app files
30
  COPY . .
31
 
32
- # Expose port
 
 
 
33
  EXPOSE 7860
34
 
35
- # Run the Flask app
36
  CMD ["python", "app.py"]
 
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 TRANSFORMERS_CACHE=/tmp \
6
+ HF_HOME=/tmp \
7
+ XDG_CACHE_HOME=/tmp \
8
+ PYTHONUNBUFFERED=1
9
 
10
+ # Install system dependencies
 
 
 
11
  RUN apt-get update && apt-get install -y \
12
  poppler-utils \
13
  tesseract-ocr \
 
14
  libglib2.0-0 \
15
  libsm6 \
16
  libxext6 \
17
  libxrender-dev \
18
+ build-essential \
19
+ && apt-get clean \
20
  && rm -rf /var/lib/apt/lists/*
21
 
22
+ # Set working directory
23
+ WORKDIR /app
24
+
25
+ # Copy requirements and install
26
  COPY requirements.txt .
27
  RUN pip install --no-cache-dir -r requirements.txt
28
 
 
 
 
29
  # Copy app files
30
  COPY . .
31
 
32
+ # Create upload directory
33
+ RUN mkdir -p /tmp/uploads
34
+
35
+ # Expose port (optional for HF Spaces)
36
  EXPOSE 7860
37
 
38
+ # Start the Flask app
39
  CMD ["python", "app.py"]