docker: latest backend dockerization attempt but crash
This commit is contained in:
+17
-10
@@ -1,4 +1,5 @@
|
|||||||
FROM ubuntu:22.04
|
FROM --platform=linux/amd64 ubuntu:22.04
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -12,13 +13,15 @@ RUN apt-get update && apt-get install -y \
|
|||||||
python3-pip \
|
python3-pip \
|
||||||
python3-wheel \
|
python3-wheel \
|
||||||
build-essential \
|
build-essential \
|
||||||
# Chrome dependencies - comprehensive list
|
|
||||||
fonts-liberation \
|
fonts-liberation \
|
||||||
|
libasound-dev \
|
||||||
libasound2 \
|
libasound2 \
|
||||||
|
portaudio19-dev \
|
||||||
libatk-bridge2.0-0 \
|
libatk-bridge2.0-0 \
|
||||||
libdrm2 \
|
libdrm2 \
|
||||||
libxcomposite1 \
|
libxcomposite1 \
|
||||||
libxdamage1 \
|
libxdamage1 \
|
||||||
|
libfontconfig1 \
|
||||||
libxrandr2 \
|
libxrandr2 \
|
||||||
libgbm1 \
|
libgbm1 \
|
||||||
libxss1 \
|
libxss1 \
|
||||||
@@ -61,22 +64,26 @@ COPY .env .
|
|||||||
COPY config.ini .
|
COPY config.ini .
|
||||||
|
|
||||||
# Install Chrome and ChromeDriver from chrome-for-testing
|
# 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 && \
|
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/136.0.7103.113/linux64/chromedriver-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-linux64.zip && \
|
unzip chrome-headless-shell-linux64.zip && \
|
||||||
unzip chromedriver-linux64.zip && \
|
unzip chromedriver-linux64.zip && \
|
||||||
mkdir -p /opt/google && \
|
mkdir -p /opt/google && \
|
||||||
ls -la && \
|
ls -la && \
|
||||||
mv chrome-linux64 /opt/google/chrome && \
|
mv chrome-headless-shell-linux64 /opt/google/chrome && \
|
||||||
mv chromedriver-linux64/chromedriver /usr/local/bin/chromedriver && \
|
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
|
chmod +x /usr/local/bin/chromedriver
|
||||||
|
|
||||||
RUN ln -s /opt/google/chrome/chrome /usr/local/bin/chrome
|
RUN ln -s /opt/google/chrome/chrome /usr/local/bin/chrome
|
||||||
|
|
||||||
# Verify Chrome and ChromeDriver installation
|
# Debug ChromeDriver
|
||||||
RUN google-chrome --version
|
RUN echo "=== ChromeDriver Debug ===" && \
|
||||||
RUN chromedriver --version > /dev/null 2>&1
|
/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 CHROME_BIN=/opt/google/chrome/chrome
|
||||||
ENV CHROMEDRIVER_PATH=/usr/local/bin/chromedriver
|
ENV CHROMEDRIVER_PATH=/usr/local/bin/chromedriver
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ services:
|
|||||||
- ./searxng:/etc/searxng:rw
|
- ./searxng:/etc/searxng:rw
|
||||||
environment:
|
environment:
|
||||||
- SEARXNG_BASE_URL=${SEARXNG_BASE_URL:-http://localhost:8080/}
|
- 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_WORKERS=4
|
||||||
- UWSGI_THREADS=4
|
- UWSGI_THREADS=4
|
||||||
cap_add:
|
cap_add:
|
||||||
|
|||||||
+13
-2
@@ -46,8 +46,9 @@ def get_chrome_path() -> str:
|
|||||||
"/usr/bin/chromium-browser",
|
"/usr/bin/chromium-browser",
|
||||||
"/usr/bin/chromium",
|
"/usr/bin/chromium",
|
||||||
"/opt/chrome/chrome",
|
"/opt/chrome/chrome",
|
||||||
"opt/google/chrome/chrome",
|
|
||||||
"/usr/local/bin/chrome",
|
"/usr/local/bin/chrome",
|
||||||
|
"/opt/google/chrome/chrome-headless-shell",
|
||||||
|
"/opt/google/chrome/chrome",
|
||||||
#"/app/chrome_bundle/chrome136/chrome-linux64"
|
#"/app/chrome_bundle/chrome136/chrome-linux64"
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -84,6 +85,7 @@ def install_chromedriver() -> str:
|
|||||||
# if os.path.exists("/app/chrome_bundle/chrome136/chromedriver"):
|
# if os.path.exists("/app/chrome_bundle/chrome136/chromedriver"):
|
||||||
# print("Using bundled ChromeDriver from /app/chrome_bundle/chrome136/chromedriver")
|
# print("Using bundled ChromeDriver from /app/chrome_bundle/chrome136/chromedriver")
|
||||||
# chromedriver_path = "/app/chrome_bundle/chrome136/chromedriver"
|
# chromedriver_path = "/app/chrome_bundle/chrome136/chromedriver"
|
||||||
|
print("path:", chromedriver_path)
|
||||||
if not chromedriver_path:
|
if not chromedriver_path:
|
||||||
try:
|
try:
|
||||||
print("ChromeDriver not found, attempting to install automatically...")
|
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
|
chrome_options.binary_location = chrome_path
|
||||||
|
|
||||||
if headless:
|
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-gpu")
|
||||||
chrome_options.add_argument("--disable-webgl")
|
chrome_options.add_argument("--disable-webgl")
|
||||||
user_data_dir = tempfile.mkdtemp()
|
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(f"--accept-lang={lang}-{lang.upper()},{lang};q=0.9")
|
||||||
chrome_options.add_argument("--timezone=Europe/Paris")
|
chrome_options.add_argument("--timezone=Europe/Paris")
|
||||||
chrome_options.add_argument("--no-sandbox")
|
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("--disable-dev-shm-usage")
|
||||||
chrome_options.add_argument("--mute-audio")
|
chrome_options.add_argument("--mute-audio")
|
||||||
chrome_options.add_argument("--disable-notifications")
|
chrome_options.add_argument("--disable-notifications")
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ sleep 4
|
|||||||
docker stop $(docker ps -a -q)
|
docker stop $(docker ps -a -q)
|
||||||
echo "All containers stopped"
|
echo "All containers stopped"
|
||||||
|
|
||||||
|
# export searxng secret key
|
||||||
|
export SEARXNG_SECRET_KEY=$(openssl rand -hex 32)
|
||||||
|
|
||||||
if [ "$1" = "full" ]; then
|
if [ "$1" = "full" ]; then
|
||||||
# First start backend and wait for it to be healthy
|
# First start backend and wait for it to be healthy
|
||||||
echo "Full docker deployement. Starting backend service..."
|
echo "Full docker deployement. Starting backend service..."
|
||||||
|
|||||||
Reference in New Issue
Block a user