diff --git a/Dockerfile.template b/Dockerfile.template index ec28f91..5f13458 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -38,6 +38,9 @@ RUN usermod -a -G audio,video,tty chromium RUN curl -skL https://raw.githubusercontent.com/balena-labs-projects/audio/master/scripts/alsa-bridge/debian-setup.sh| sh ENV PULSE_SERVER=tcp:audio:4317 +# install socat to forard chromiums debug port +RUN install_packages socat + COPY VERSION . # Start app diff --git a/readme.md b/readme.md index b556d3e..997d779 100644 --- a/readme.md +++ b/readme.md @@ -92,7 +92,7 @@ The following environment variables allow configuration of the `browser` block: |`WINDOW_SIZE`|`x,y`|Detected screen resolution|Sets the browser window size, such as `800,600`.
**Note:** Reverse the dimensions if you also rotate the display to `left` or `right` | |`WINDOW_POSITION`|`x,y`|`0,0`|Specifies the browser window position on the screen| |`API_PORT`|port number|5011|Specifies the port number the API runs on| -|`REMOTE_DEBUG_PORT`|port number|35173|Specifies the port number the chrome remote debugger runs on| +|`REMOTE_DEBUG_PORT`|port number|35173|Specifies the port number the chrome remote debugger runs on. The actual port a client (like chrome) might connect to it will be REMOTE_DEBUG_PORT + 1 due to a deprecation of [this chromium feature](https://issues.chromium.org/issues/41487252).| |`AUTO_REFRESH`|interval|0 (disabled)|Specifies the number of seconds before the page automatically refreshes| --- diff --git a/src/start.sh b/src/start.sh index 6e89c01..1610f4f 100644 --- a/src/start.sh +++ b/src/start.sh @@ -68,4 +68,13 @@ environment="${environment::-1}" # launch Chromium and whitelist the enVars so that they pass through to the su session su -w $environment -c "export DISPLAY=:$DISPLAY_NUM && startx /usr/src/app/startx.sh $CURSOR" - chromium + +# forward the chromium remote debugging port from 0.0.0.0 to localhost to deal with the dropped support to listen on all interfaces (https://issues.chromium.org/issues/41487252) +REMOTE_DEBUG_PORT=${REMOTE_DEBUG_PORT:-35173} +REMOTE_DEBUG_FORWARD_PORT=$(($REMOTE_DEBUG_PORT+1)) +echo "Forwarding remote debugging port 0.0.0.0:$REMOTE_DEBUG_FORWARD_PORT to (internal) localhost:$REMOTE_DEBUG_PORT" +socat TCP-LISTEN:${REMOTE_DEBUG_FORWARD_PORT},fork,reuseaddr TCP:localhost:${REMOTE_DEBUG_PORT} & + +# TODO: We should use REMOTE_DEBUG_PORT as the main env var, and handle the forwarding internally instead of this workaround-convention. The main api to a user should remain REMOTE_DEBUG_PORT + balena-idle