broadfield-dev commited on
Commit
5a7ca89
·
verified ·
1 Parent(s): a074fa0

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -26
Dockerfile CHANGED
@@ -1,36 +1,17 @@
1
- # Use an official Python runtime as a parent image
2
  FROM python:3.10-slim
3
 
4
- # Install system dependencies (poppler-utils and tesseract-ocr)
5
  RUN apt-get update && apt-get install -y \
6
- poppler-utils \
7
- tesseract-ocr \
8
- libtesseract-dev \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- # Create a non-root user
12
- RUN useradd -m appuser
13
-
14
- # Set working directory
15
  WORKDIR /app
16
-
17
- # Copy requirements.txt and install Python dependencies
18
  COPY requirements.txt .
19
  RUN pip install --no-cache-dir -r requirements.txt
 
20
 
21
- # Copy the app code and templates
22
- COPY app.py .
23
- COPY templates /app/templates/
24
-
25
- # Switch to non-root user
26
- USER appuser
27
-
28
- EXPOSE 7860
29
-
30
- ENV PYTHONUNBUFFERED=1
31
- ENV FLASK_APP=app.py
32
 
33
- # Gunicorn with increased timeout and gevent workers for better handling of I/O bound tasks (like network/file ops)
34
- # Adjust workers based on your Space's CPU cores.
35
- # Timeout is for a single request/response cycle. Streaming should keep this alive.
36
- CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--worker-class", "gevent", "--timeout", "300", "app:app"]
 
 
1
  FROM python:3.10-slim
2
 
3
+ # Install wkhtmltopdf and dependencies
4
  RUN apt-get update && apt-get install -y \
5
+ wkhtmltopdf \
 
 
6
  && rm -rf /var/lib/apt/lists/*
7
 
 
 
 
 
8
  WORKDIR /app
 
 
9
  COPY requirements.txt .
10
  RUN pip install --no-cache-dir -r requirements.txt
11
+ COPY . .
12
 
13
+ # Ensure the temp directory is writable
14
+ RUN mkdir -p /app/temp && chmod -R 777 /app/temp
 
 
 
 
 
 
 
 
 
15
 
16
+ ENV PORT=7860
17
+ CMD ["python", "app.py"]