Преглед изворни кода

fix chrome trying to use novnc in docker when its not available

Nick Sweeting пре 1 година
родитељ
комит
497d3e9c2d
2 измењених фајлова са 8 додато и 2 уклоњено
  1. 1 2
      Dockerfile
  2. 7 0
      bin/docker_entrypoint.sh

+ 1 - 2
Dockerfile

@@ -214,7 +214,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=apt-$TARGETARCH$T
         at-spi2-common fonts-liberation fonts-noto-color-emoji fonts-tlwg-loma-otf fonts-unifont libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libavahi-client3 \
         libavahi-common-data libavahi-common3 libcups2 libfontenc1 libice6 libnspr4 libnss3 libsm6 libunwind8 \
         libxaw7 libxcomposite1 libxdamage1 libxfont2 \
-        libxkbfile1 libxmu6 libxpm4 libxt6 x11-xkb-utils xfonts-encodings \
+        libxkbfile1 libxmu6 libxpm4 libxt6 x11-xkb-utils x11-utils xfonts-encodings \
         # xfonts-scalable xfonts-utils xserver-common xvfb \
         # chrome can run without dbus/upower technically, it complains about missing dbus but should run ok anyway
         # libxss1 dbus dbus-x11 upower \
@@ -288,7 +288,6 @@ RUN openssl rand -hex 16 > /etc/machine-id
 ENV IN_DOCKER=True \
     SYSTEM_LIB_DIR=/app/lib \
     SYSTEM_TMP_DIR=/tmp \
-    DISPLAY=novnc:0.0 \
     GOOGLE_API_KEY=no \
     GOOGLE_DEFAULT_CLIENT_ID=no \
     GOOGLE_DEFAULT_CLIENT_SECRET=no \

+ 7 - 0
bin/docker_entrypoint.sh

@@ -81,6 +81,13 @@ else
     mkdir -p "$DATA_DIR/logs"
 fi
 
+# check if novnc x11 $DISPLAY is available
+export DISPLAY="${DISPLAY:-"novnc:0.0"}"
+if ! xdpyinfo > /dev/null 2>&1; then
+    # cant connect to x11 display, unset it so that chrome doesn't try to connect to it and hang indefinitely
+    unset DISPLAY
+fi
+
 # force set the ownership of the data dir contents to the archivebox user and group
 # this is needed because Docker Desktop often does not map user permissions from the host properly
 chown $PUID:$PGID "$DATA_DIR"