docker: latest backend dockerization attempt but crash

This commit is contained in:
martin legrand
2025-05-29 15:34:23 +02:00
parent 58656ab43c
commit 95aeaf74fa
4 changed files with 34 additions and 13 deletions
+17 -10
View File
@@ -1,4 +1,5 @@
FROM ubuntu:22.04
FROM --platform=linux/amd64 ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
WORKDIR /app
@@ -12,13 +13,15 @@ RUN apt-get update && apt-get install -y \
python3-pip \
python3-wheel \
build-essential \
# Chrome dependencies - comprehensive list
fonts-liberation \
libasound-dev \
libasound2 \
portaudio19-dev \
libatk-bridge2.0-0 \
libdrm2 \
libxcomposite1 \
libxdamage1 \
libfontconfig1 \
libxrandr2 \
libgbm1 \
libxss1 \
@@ -61,22 +64,26 @@ COPY .env .
COPY config.ini .
# Install Chrome and ChromeDriver from chrome-for-testing
RUN wget -O chrome-linux64.zip https://storage.googleapis.com/chrome-for-testing-public/136.0.7103.113/linux64/chrome-linux64.zip && \
wget -O chromedriver-linux64.zip https://storage.googleapis.com/chrome-for-testing-public/136.0.7103.113/linux64/chromedriver-linux64.zip && \
unzip chrome-linux64.zip && \
RUN wget -O chrome-headless-shell-linux64.zip https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.55/linux64/chrome-headless-shell-linux64.zip && \
wget -O chromedriver-linux64.zip https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.55/linux64/chromedriver-linux64.zip && \
unzip chrome-headless-shell-linux64.zip && \
unzip chromedriver-linux64.zip && \
mkdir -p /opt/google && \
ls -la && \
mv chrome-linux64 /opt/google/chrome && \
mv chrome-headless-shell-linux64 /opt/google/chrome && \
mv chromedriver-linux64/chromedriver /usr/local/bin/chromedriver && \
chmod +x /opt/google/chrome/chrome && \
chmod +x /opt/google/chrome/chrome-headless-shell && \
chmod +x /usr/local/bin/chromedriver
RUN ln -s /opt/google/chrome/chrome /usr/local/bin/chrome
# Verify Chrome and ChromeDriver installation
RUN google-chrome --version
RUN chromedriver --version > /dev/null 2>&1
# Debug ChromeDriver
RUN echo "=== ChromeDriver Debug ===" && \
/usr/local/bin/chromedriver --version && \
echo "Chrome binary:" && \
/opt/google/chrome/chrome --version && \
echo "Testing ChromeDriver startup:" && \
timeout 5 /usr/local/bin/chromedriver --port=9999 || echo "ChromeDriver failed to start"
ENV CHROME_BIN=/opt/google/chrome/chrome
ENV CHROMEDRIVER_PATH=/usr/local/bin/chromedriver
+1 -1
View File
@@ -34,7 +34,7 @@ services:
- ./searxng:/etc/searxng:rw
environment:
- SEARXNG_BASE_URL=${SEARXNG_BASE_URL:-http://localhost:8080/}
- SEARXNG_SECRET_KEY=$(openssl rand -hex 32)
- SEARXNG_SECRET_KEY=${SEARXNG_SECRET_KEY}
- UWSGI_WORKERS=4
- UWSGI_THREADS=4
cap_add:
+13 -2
View File
@@ -46,8 +46,9 @@ def get_chrome_path() -> str:
"/usr/bin/chromium-browser",
"/usr/bin/chromium",
"/opt/chrome/chrome",
"opt/google/chrome/chrome",
"/usr/local/bin/chrome",
"/opt/google/chrome/chrome-headless-shell",
"/opt/google/chrome/chrome",
#"/app/chrome_bundle/chrome136/chrome-linux64"
]
@@ -84,6 +85,7 @@ def install_chromedriver() -> str:
# if os.path.exists("/app/chrome_bundle/chrome136/chromedriver"):
# print("Using bundled ChromeDriver from /app/chrome_bundle/chrome136/chromedriver")
# chromedriver_path = "/app/chrome_bundle/chrome136/chromedriver"
print("path:", chromedriver_path)
if not chromedriver_path:
try:
print("ChromeDriver not found, attempting to install automatically...")
@@ -132,7 +134,8 @@ def create_driver(headless=False, stealth_mode=True, crx_path="./crx/nopecha.crx
chrome_options.binary_location = chrome_path
if headless:
chrome_options.add_argument("--headless")
#chrome_options.add_argument("--headless")
chrome_options.add_argument("--headless=new")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--disable-webgl")
user_data_dir = tempfile.mkdtemp()
@@ -142,6 +145,14 @@ def create_driver(headless=False, stealth_mode=True, crx_path="./crx/nopecha.crx
chrome_options.add_argument(f"--accept-lang={lang}-{lang.upper()},{lang};q=0.9")
chrome_options.add_argument("--timezone=Europe/Paris")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--remote-debugging-port=9222')
chrome_options.add_argument('--disable-extensions')
chrome_options.add_argument('--disable-background-timer-throttling')
chrome_options.add_argument('--disable-backgrounding-occluded-windows')
chrome_options.add_argument('--disable-renderer-backgrounding')
chrome_options.add_argument('--disable-features=TranslateUI')
chrome_options.add_argument('--disable-ipc-flooding-protection')
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--mute-audio")
chrome_options.add_argument("--disable-notifications")
+3
View File
@@ -96,6 +96,9 @@ sleep 4
docker stop $(docker ps -a -q)
echo "All containers stopped"
# export searxng secret key
export SEARXNG_SECRET_KEY=$(openssl rand -hex 32)
if [ "$1" = "full" ]; then
# First start backend and wait for it to be healthy
echo "Full docker deployement. Starting backend service..."