Hi,
I have an older project that I want to use (I already updated a few things but that is ongoing). I was pretty sure I already could remote debugging (6 years ago) but when I tried it yesterday it didn’t work anymore.
When the container starting it even says “DevTools listening on ws://127.0.0.1:9222/devtools/browser/453890f6-779b-405a-a5d7-508a698a89e7” in the logs. Shouldn’t I be able, when I type the remote ip address of the Pi with the port, to see the dev tools? I think it worked that way a few years ago. But the connection is always refused…
Maybe someone knows if something changed or what my fault is. For more context, here the dockerfile:
FROM balenalib/%%BALENA_MACHINE_NAME%%-node:14.17-bullseye-build as build
# Install other apt deps
RUN apt-get update && apt-get install -y \
apt-utils \
....
# Set Xorg and FLUXBOX preferences
RUN mkdir ~/.fluxbox
RUN echo "xset s off" > ~/.fluxbox/startup && echo "xserver-command=X -s 0 dpms" >> ~/.fluxbox/startup
RUN echo "#!/bin/bash" > /etc/X11/xinit/xserverrc \
&& echo "" >> /etc/X11/xinit/xserverrc \
&& echo 'exec /usr/bin/X -s 0 dpms -nocursor -nolisten tcp "$@"' >> /etc/X11/xinit/xserverrc
# Move to app dir
WORKDIR /usr/src/app
# Move package.json to filesystem
COPY ./app/package.json ./
# Install npm modules for the application
# Install dev deps so we can build app
RUN JOBS=MAX npm install --unsafe-perm \
&& npm cache verify && node_modules/.bin/electron-rebuild
# Move app to filesystem
COPY ./app ./
# Build react app
RUN JOBS=MAX npm run build
## uncomment if you want systemd
ENV INITSYSTEM on
# Expose the debugging port
EXPOSE 9222
# Start app
CMD ["bash", "/usr/src/app/start.sh"]
Additionally the start.sh:
#!/bin/bash
export URL_LAUNCHER_NODE=1
export NODE_ENV=production
# By default docker gives us 64MB of shared memory size but to display heavy
# pages we need more.
umount /dev/shm && mount -t tmpfs shm /dev/shm
# using local electron module instead of the global electron lets you
# easily control specific version dependency between your app and electron itself.
# the syntax below starts an X istance with ONLY our electronJS fired up,
# it saves you a LOT of resources avoiding full-desktops envs
rm /tmp/.X0-lock &>/dev/null || true
startx /usr/src/app/node_modules/electron/dist/electron /usr/src/app --no-sandbox --enable-logging --remote-debugging-port=9222
And last but not least main.js:
app.commandLine.appendSwitch("remote-debugging-port", "9222");
// enable touch events if your device supports them
if (electronConfig.URL_LAUNCHER_TOUCH) {
app.commandLine.appendSwitch("--touch-devices");