42Cummer commited on
Commit
209ebac
·
verified ·
1 Parent(s): 0878044
Files changed (1) hide show
  1. Dockerfile +34 -36
Dockerfile CHANGED
@@ -1,36 +1,34 @@
1
- FROM python:3.10
2
-
3
- # Install basic dependencies
4
- RUN apt-get update && apt-get install -y \
5
- wget \
6
- gnupg \
7
- unzip \
8
- curl \
9
- && apt-get clean \
10
- && rm -rf /var/lib/apt/lists/*
11
-
12
- WORKDIR /app
13
-
14
- # Upgrade pip and install requirements
15
- RUN pip install --upgrade pip
16
- COPY requirements.txt .
17
- RUN pip install -r requirements.txt
18
-
19
- # Install Playwright and download the required browsers
20
- RUN playwright install --with-deps
21
-
22
- # Create and switch to a non-root user
23
- RUN useradd -m -u 1000 user
24
- USER user
25
- ENV PATH="/home/user/.local/bin:$PATH"
26
-
27
- # Ensure Playwright browsers are installed for the non-root user
28
- RUN playwright install
29
-
30
- # Verify the installation and show the exact path
31
- RUN playwright --version && ls -la /tmp/playwright-browsers/ && find /tmp/playwright-browsers/ -name "chrome" -type f
32
-
33
- COPY . .
34
-
35
- CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]
36
-
 
1
+ # --- Base on a Playwright-supported OS ---
2
+ FROM ubuntu:22.04
3
+
4
+ ENV DEBIAN_FRONTEND=noninteractive \
5
+ PYTHONUNBUFFERED=1 \
6
+ PIP_NO_CACHE_DIR=1
7
+
8
+ # System deps + fonts Playwright/Chromium need
9
+ RUN apt-get update && apt-get install -y \
10
+ python3 python3-pip python3-venv \
11
+ curl wget unzip ca-certificates gnupg \
12
+ # GUI/codec libs that Chromium needs even when headless
13
+ libglib2.0-0 libnss3 libnspr4 libx11-xcb1 libxcomposite1 libxdamage1 libxfixes3 \
14
+ libxrandr2 libxshmfence1 libxext6 libxss1 libgbm1 \
15
+ libgtk-3-0 libatk1.0-0 libatk-bridge2.0-0 libcairo2 libpango-1.0-0 libcups2 \
16
+ fonts-liberation fonts-ubuntu fonts-noto-color-emoji fonts-unifont \
17
+ xdg-utils lsb-release && \
18
+ rm -rf /var/lib/apt/lists/*
19
+
20
+ WORKDIR /app
21
+
22
+ # Python deps
23
+ COPY requirements.txt .
24
+ RUN python3 -m pip install -r requirements.txt
25
+
26
+ # Install Playwright browsers + (re)check deps on this Ubuntu
27
+ RUN python3 -m playwright install --with-deps
28
+
29
+ # Copy app
30
+ COPY . .
31
+
32
+ EXPOSE 7860
33
+ CMD ["python3", "app.py"]
34
+