ABDALLALSWAITI commited on
Commit
d895233
·
verified ·
1 Parent(s): 37b4054

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -9
Dockerfile CHANGED
@@ -1,5 +1,6 @@
1
  FROM python:3.11-slim
2
 
 
3
  WORKDIR /app
4
 
5
  # Install system dependencies
@@ -35,30 +36,37 @@ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
35
  apt-get install -y nodejs && \
36
  rm -rf /var/lib/apt/lists/*
37
 
 
 
 
38
  # Copy dependency files
39
- COPY requirements.txt package.json ./
40
 
41
  # Install Python and Node dependencies
42
  RUN pip install --no-cache-dir -r requirements.txt
43
  RUN npm install
44
 
45
  # Copy application files
46
- COPY app.py puppeteer_pdf.js ./
47
 
48
  # Make puppeteer script executable
49
  RUN chmod +x puppeteer_pdf.js
50
 
51
- # Create and set permissions for 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 PYTHONUNBUFFERED=1
58
- ENV PORT=7860
 
59
 
60
  # Expose port
61
  EXPOSE 7860
62
 
63
- # Start application with keep-alive settings
64
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--timeout-keep-alive", "75"]
 
1
  FROM python:3.11-slim
2
 
3
+ # Set working directory
4
  WORKDIR /app
5
 
6
  # Install system dependencies
 
36
  apt-get install -y nodejs && \
37
  rm -rf /var/lib/apt/lists/*
38
 
39
+ # Create user (required for HF Spaces)
40
+ RUN useradd -m -u 1000 user
41
+
42
  # Copy dependency files
43
+ COPY --chown=user requirements.txt package.json ./
44
 
45
  # Install Python and Node dependencies
46
  RUN pip install --no-cache-dir -r requirements.txt
47
  RUN npm install
48
 
49
  # Copy application files
50
+ COPY --chown=user app.py puppeteer_pdf.js ./
51
 
52
  # Make puppeteer script executable
53
  RUN chmod +x puppeteer_pdf.js
54
 
55
+ # Set permissions
56
  RUN mkdir -p /tmp && chmod 777 /tmp
57
 
58
+ # Switch to user
59
+ USER user
60
+
61
  # Environment variables
62
+ ENV HOME=/home/user \
63
+ PATH=/home/user/.local/bin:$PATH \
64
+ PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
65
+ PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium \
66
+ PYTHONUNBUFFERED=1
67
 
68
  # Expose port
69
  EXPOSE 7860
70
 
71
+ # Start application
72
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]