wuhp commited on
Commit
42ea825
·
verified ·
1 Parent(s): a2c6146

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +44 -33
Dockerfile CHANGED
@@ -1,43 +1,54 @@
1
  FROM python:3.12-slim
2
 
3
- ENV PYTHONUNBUFFERED=1
4
- ENV PORT=7860
5
- ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
6
-
7
- RUN apt-get update && apt-get install -y \
8
- wget \
9
- curl \
10
- git \
11
- unzip \
12
- xvfb \
13
- libnss3 \
14
- libatk1.0-0 \
15
- libatk-bridge2.0-0 \
16
- libcups2 \
17
- libdrm2 \
18
- libxkbcommon0 \
19
- libxcomposite1 \
20
- libxdamage1 \
21
- libxfixes3 \
22
- libxrandr2 \
23
- libgbm1 \
24
- libasound2 \
25
- libpangocairo-1.0-0 \
26
- libpango-1.0-0 \
27
- libcairo2 \
28
- libx11-6 \
29
- libxext6 \
30
- libxrender1 \
31
- fonts-liberation \
32
  && rm -rf /var/lib/apt/lists/*
33
 
 
34
  WORKDIR /app
35
 
36
- COPY requirements.txt .
 
 
 
 
 
 
 
 
37
 
38
- RUN pip install --no-cache-dir -r requirements.txt
39
  RUN playwright install chromium
 
 
 
 
 
 
 
 
 
 
40
 
41
- COPY . .
 
 
42
 
43
- CMD uvicorn app:app --host 0.0.0.0 --port 7860
 
 
1
  FROM python:3.12-slim
2
 
3
+ # Environment setup
4
+ ENV PYTHONUNBUFFERED=1 \
5
+ PORT=7860 \
6
+ PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
7
+ PYTHONDONTWRITEBYTECODE=1 \
8
+ PIP_NO_CACHE_DIR=1
9
+
10
+ # Install system dependencies for Playwright + Chromium
11
+ RUN apt-get update && apt-get install -y --no-install-recommends \
12
+ # Core dependencies
13
+ wget curl git unzip xvfb \
14
+ # Playwright/Chromium dependencies
15
+ libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \
16
+ libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 \
17
+ libgbm1 libasound2 libpangocairo-1.0-0 libpango-1.0-0 \
18
+ libcairo2 libx11-6 libxext6 libxrender1 fonts-liberation \
19
+ # Build tools (for any native packages)
20
+ gcc g++ make \
 
 
 
 
 
 
 
 
 
 
 
21
  && rm -rf /var/lib/apt/lists/*
22
 
23
+ # Create app directory
24
  WORKDIR /app
25
 
26
+ # Install Python dependencies
27
+ COPY << 'EOF' /app/requirements.txt
28
+ fastapi>=0.109.0
29
+ uvicorn[standard]>=0.27.0
30
+ playwright>=1.41.0
31
+ python-multipart>=0.0.6
32
+ EOF
33
+
34
+ RUN pip install -r requirements.txt
35
 
36
+ # Install Playwright browsers (Chromium only for size)
37
  RUN playwright install chromium
38
+ RUN playwright install-deps chromium 2>/dev/null || true
39
+
40
+ # Copy application code
41
+ COPY app.py /app/app.py
42
+
43
+ # Create necessary directories
44
+ RUN mkdir -p /app/scripts /app/results && chmod 755 /app/scripts /app/results
45
+
46
+ # Expose port for Hugging Face Spaces
47
+ EXPOSE 7860
48
 
49
+ # Health check
50
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
51
+ CMD curl -f http://localhost:7860/health || exit 1
52
 
53
+ # Start the application
54
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "info"]