jperkin / node-rpio

Raspberry Pi GPIO library for node.js
856 stars 123 forks source link

detect_pinmap hard codes /proc/device-tree/model causing docker issues #154

Open masahji opened 2 years ago

masahji commented 2 years ago

detect_pinmap hard codes /proc/device-tree/model causing non-privileged docker containers to fail hardware autodetect. This is a common issue that is being worked around by either A) making the container privileged B) Or wait for the container to come up then perform some kind of just in time post start remount. Both solutions are not ideal.

There was another issue that partially resolved the problem but did not address the hardware autodetect failure. See Here

On a container, /proc/device-tree is actually a symbolic link to /sys/firmware/devicetree/base, but /sys/firmware doesn't exist at all. Simply mounting /sys/firmware/devicetree/base as a volume does not appear to work.

However, you CAN mount /sys/firmware to another path while non privileged. Like so:

    volumes:
      - type: bind
        source: /sys/firmware
        target: /psys/firmware

/psys is just a made up path. So a simple solution might be to not hard code /proc/device-tree/model and allow it to be changed from gpio.init. like this:

gpio.init({
    devicetree: '/psys/firmware/devicetree/base/model',
})