simoncck commited on
Commit
24db31a
·
verified ·
1 Parent(s): 30980ef

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +72 -0
Dockerfile ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use Python 3.11 as base image
2
+ FROM python:3.11-slim
3
+
4
+ # Set environment variables
5
+ ENV PYTHONUNBUFFERED=1
6
+ ENV PYTHONDONTWRITEBYTECODE=1
7
+
8
+ # Create user for security (required by Hugging Face Spaces)
9
+ RUN useradd -m -u 1000 user
10
+ USER user
11
+
12
+ # Set environment paths
13
+ ENV HOME=/home/user \
14
+ PATH=/home/user/.local/bin:$PATH
15
+
16
+ # Set working directory
17
+ WORKDIR $HOME/app
18
+
19
+ # Install system dependencies as root
20
+ USER root
21
+ RUN apt-get update && apt-get install -y \
22
+ wget \
23
+ gnupg \
24
+ ca-certificates \
25
+ fonts-liberation \
26
+ libasound2 \
27
+ libatk-bridge2.0-0 \
28
+ libatk1.0-0 \
29
+ libatspi2.0-0 \
30
+ libcups2 \
31
+ libdbus-1-3 \
32
+ libdrm2 \
33
+ libgtk-3-0 \
34
+ libnspr4 \
35
+ libnss3 \
36
+ libwayland-client0 \
37
+ libx11-6 \
38
+ libx11-xcb1 \
39
+ libxcb1 \
40
+ libxcomposite1 \
41
+ libxdamage1 \
42
+ libxext6 \
43
+ libxfixes3 \
44
+ libxrandr2 \
45
+ libxss1 \
46
+ libxtst6 \
47
+ xdg-utils \
48
+ && rm -rf /var/lib/apt/lists/*
49
+
50
+ # Switch back to user
51
+ USER user
52
+
53
+ # Copy requirements first for better caching
54
+ COPY --chown=user requirements.txt .
55
+
56
+ # Install Python dependencies
57
+ RUN pip install --no-cache-dir --upgrade pip
58
+ RUN pip install --no-cache-dir -r requirements.txt
59
+
60
+ # Install Playwright browsers
61
+ RUN playwright install chromium
62
+ RUN playwright install-deps chromium
63
+
64
+ # Copy application code
65
+ COPY --chown=user . .
66
+
67
+ # Expose the port that Hugging Face Spaces expects
68
+ EXPOSE 7860
69
+
70
+ # Command to run the application
71
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "300", "--keep-alive", "2", "app:app"]
72
+