ABDALLALSWAITI commited on
Commit
c8ffee8
·
verified ·
1 Parent(s): 84ae46e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -17
Dockerfile CHANGED
@@ -7,14 +7,6 @@ RUN apt-get update && apt-get install -y \
7
  curl \
8
  wget \
9
  gnupg \
10
- && rm -rf /var/lib/apt/lists/*
11
-
12
- # Install Node.js 20
13
- RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
14
- && apt-get install -y nodejs
15
-
16
- # Install Chromium dependencies
17
- RUN apt-get update && apt-get install -y \
18
  chromium \
19
  chromium-sandbox \
20
  fonts-liberation \
@@ -36,27 +28,38 @@ RUN apt-get update && apt-get install -y \
36
  xdg-utils \
37
  && rm -rf /var/lib/apt/lists/*
38
 
39
- # Copy and install Python dependencies
40
- COPY requirements.txt .
41
- RUN pip install --no-cache-dir -r requirements.txt
 
 
 
 
42
 
43
- # Copy and install Node dependencies
44
- COPY package.json .
45
  RUN npm install
46
 
47
  # Copy application files
48
  COPY app.py puppeteer_pdf.js ./
 
 
49
  RUN chmod +x puppeteer_pdf.js
50
 
51
- # Create temp directory
52
  RUN mkdir -p /tmp && chmod 777 /tmp
53
 
54
  # Environment variables
55
  ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
56
  ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
57
- ENV PORT=7860
58
 
 
59
  EXPOSE 7860
60
 
61
- # Start command
62
- CMD uvicorn app:app --host 0.0.0.0 --port 7860 --timeout-keep-alive 120
 
 
 
 
 
7
  curl \
8
  wget \
9
  gnupg \
 
 
 
 
 
 
 
 
10
  chromium \
11
  chromium-sandbox \
12
  fonts-liberation \
 
28
  xdg-utils \
29
  && rm -rf /var/lib/apt/lists/*
30
 
31
+ # Install Node.js 20
32
+ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
33
+ apt-get install -y nodejs && \
34
+ rm -rf /var/lib/apt/lists/*
35
+
36
+ # Copy dependency files
37
+ COPY requirements.txt package.json ./
38
 
39
+ # Install Python and Node dependencies
40
+ RUN pip install --no-cache-dir -r requirements.txt
41
  RUN npm install
42
 
43
  # Copy application files
44
  COPY app.py puppeteer_pdf.js ./
45
+
46
+ # Make puppeteer script executable
47
  RUN chmod +x puppeteer_pdf.js
48
 
49
+ # Create and set permissions for temp directory
50
  RUN mkdir -p /tmp && chmod 777 /tmp
51
 
52
  # Environment variables
53
  ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
54
  ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
55
+ ENV PYTHONUNBUFFERED=1
56
 
57
+ # Expose port
58
  EXPOSE 7860
59
 
60
+ # Health check
61
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
62
+ CMD curl -f http://localhost:7860/health || exit 1
63
+
64
+ # Start application
65
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]