Spaces:
Sleeping
Sleeping
try forum suggestion
Browse files- Dockerfile +14 -6
- app.py +2 -2
Dockerfile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
| 3 |
-
# Install basic dependencies
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
wget \
|
| 6 |
gnupg \
|
|
@@ -11,13 +11,21 @@ RUN apt-get update && apt-get install -y \
|
|
| 11 |
|
| 12 |
WORKDIR /app
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
RUN pip install -r requirements.txt
|
| 16 |
|
| 17 |
-
# Install Playwright
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# Verify the installation and show the exact path
|
| 23 |
RUN playwright --version && ls -la /tmp/playwright-browsers/ && find /tmp/playwright-browsers/ -name "chrome" -type f
|
|
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
| 3 |
+
# Install basic dependencies
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
wget \
|
| 6 |
gnupg \
|
|
|
|
| 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
|
app.py
CHANGED
|
@@ -254,8 +254,8 @@ def seek():
|
|
| 254 |
}
|
| 255 |
# Use Playwright to handle redirects and wait for page to load
|
| 256 |
with sync_playwright() as p:
|
| 257 |
-
# Use the known working Chrome executable path
|
| 258 |
-
executable_path = "/
|
| 259 |
print(f"Using Chrome executable: {executable_path}")
|
| 260 |
|
| 261 |
browser = p.chromium.launch(
|
|
|
|
| 254 |
}
|
| 255 |
# Use Playwright to handle redirects and wait for page to load
|
| 256 |
with sync_playwright() as p:
|
| 257 |
+
# Use the known working Chrome executable path (for non-root user)
|
| 258 |
+
executable_path = "/home/user/.cache/ms-playwright/chromium-*/chrome-linux/chrome"
|
| 259 |
print(f"Using Chrome executable: {executable_path}")
|
| 260 |
|
| 261 |
browser = p.chromium.launch(
|