SignalK / signalk-server

An implementation of a Signal K central server for boats.
http://signalk.org
Apache License 2.0
307 stars 152 forks source link

[DOCKER][BUG] SeaTalk GPIO integration not working #1703

Open xGuIInE opened 6 months ago

xGuIInE commented 6 months ago

Hello, I was integrating a SeaTalk module to my docker signalk server, and I faced with this issue. The python script is executed using the python -u -c '${cmd}' ${options.gpio} ${options.gpioInvert}, but python is only aliased by python3, so it can't be loaded.

https://github.com/SignalK/signalk-server/blob/master/packages/streams/pigpio-seatalk.js

I fixed this using a custom Docker image:

FROM cr.signalk.io/signalk/signalk-server

USER root

RUN apt-get update
RUN apt-get install -y python3-pigpio
RUN apt-get install -y python-is-python3

USER node

python-is-python3 package does the trick.

KEGustafsson commented 6 months ago

Isn't this easiest to fix in pigpio-seatalk.js itself? To add test which python is installed and then use it.

xGuIInE commented 6 months ago

Yes... this was a workaround/temporal solution. I'm going to check if other modules use python call too and prepare a PR.

xGuIInE commented 6 months ago

@KEGustafsson after checking it further, pigpio package isn't installed in the docker image... throwing ModuleNotFoundError: No module named 'pigpio' Docker base image should be updated, maybe keeping python-is-python3 package is safer allowing to use both commands python | python3

KEGustafsson commented 6 months ago

You could add check which version of python is installed and if required packages are installed too and if not then install ones with pip. Once checked which python in use, then modify excutive part accordingly. To my understanding all changes can be done application level, no need to touch image.