Use full Chrome for interactive Reddit login
This commit is contained in:
1 parent
70d62b2da3
commit
674cd89cd7
5 files changed
+241
-3
No files matched your search
@@ -9,6 +9,9 @@ VNC_PORT="${VNC_PORT:-5900}"
|
||||
NOVNC_PORT="${NOVNC_PORT:-6080}"
|
||||
GEOMETRY="${SCREEN_GEOMETRY:-1280x800x24}"
|
||||
BROWSER_SESSION_DIR="${BROWSER_SESSION_DIR:-/app/data/browser-session}"
|
||||
CHROME_CDP_PORT="${CHROME_CDP_PORT:-9222}"
|
||||
GOOGLE_CHROME_BIN="${GOOGLE_CHROME_BIN:-google-chrome}"
|
||||
export CHROME_CDP_URL="${CHROME_CDP_URL:-http://127.0.0.1:${CHROME_CDP_PORT}}"
|
||||
export DISPLAY=":${DISPLAY_NUM}"
|
||||
|
||||
# noVNC ships under different paths depending on the distro; find the web root once.
|
||||
@@ -104,8 +107,59 @@ websockify --web "${NOVNC_WEB_DIR}" "${NOVNC_PORT}" "localhost:${VNC_PORT}" \
|
||||
>/var/log/websockify.log 2>&1 &
|
||||
NOVNC_PID=$!
|
||||
|
||||
# Start the installed consumer Google Chrome directly. Playwright attaches only
|
||||
# after Chrome is running, so the human login is not performed in a browser
|
||||
# process launched with Playwright's automation arguments.
|
||||
CHROME_PID=""
|
||||
CHROME_READY=0
|
||||
if command -v "${GOOGLE_CHROME_BIN}" >/dev/null 2>&1; then
|
||||
echo "[entrypoint] starting Google Chrome for interactive login"
|
||||
"${GOOGLE_CHROME_BIN}" \
|
||||
--user-data-dir="${BROWSER_SESSION_DIR}" \
|
||||
--remote-debugging-address=127.0.0.1 \
|
||||
--remote-debugging-port="${CHROME_CDP_PORT}" \
|
||||
--no-first-run \
|
||||
--no-default-browser-check \
|
||||
--disable-dev-shm-usage \
|
||||
--no-sandbox \
|
||||
--start-maximized \
|
||||
about:blank \
|
||||
>/var/log/google-chrome.log 2>&1 &
|
||||
CHROME_PID=$!
|
||||
|
||||
for i in $(seq 1 100); do
|
||||
if ! kill -0 "${CHROME_PID}" 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
if curl -fsS "${CHROME_CDP_URL}/json/version" >/dev/null 2>&1; then
|
||||
echo "[entrypoint] Google Chrome is ready after ${i} checks"
|
||||
CHROME_READY=1
|
||||
break
|
||||
fi
|
||||
sleep 0.2
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "${CHROME_READY}" != "1" ]; then
|
||||
echo "[entrypoint] WARNING: Google Chrome failed to start; using Playwright fallback" >&2
|
||||
if [ -n "${CHROME_PID}" ]; then
|
||||
kill "${CHROME_PID}" 2>/dev/null || true
|
||||
wait "${CHROME_PID}" 2>/dev/null || true
|
||||
fi
|
||||
rm -f \
|
||||
"${BROWSER_SESSION_DIR}/SingletonLock" \
|
||||
"${BROWSER_SESSION_DIR}/SingletonSocket" \
|
||||
"${BROWSER_SESSION_DIR}/SingletonCookie" \
|
||||
2>/dev/null || true
|
||||
CHROME_PID=""
|
||||
unset CHROME_CDP_URL
|
||||
fi
|
||||
|
||||
cleanup() {
|
||||
echo "[entrypoint] shutting down"
|
||||
if [ -n "${CHROME_PID}" ]; then
|
||||
kill "${CHROME_PID}" 2>/dev/null || true
|
||||
fi
|
||||
kill "${NOVNC_PID}" "${X11VNC_PID}" "${XVFB_PID}" 2>/dev/null || true
|
||||
wait || true
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user