Code Monkey home page Code Monkey logo

Comments (24)

dceejay avatar dceejay commented on May 24, 2024 4

seems like 2 choices... either don't install the GPIO stuff and keep the image small, or install all the tools and let it balloon.

Also It's good to leave the compile tools in while the actual install happens so that the bcrypt library gets built. However it does seem that the pip tool does drag in loads of extra weight...

I'm currently investigating how feasible it would be to leave the gpio "outside" of docker - ie on the Pi Host and then connect to it from the container instead by using pigpiod as an alternative. That would save installing any of the gpio code inside.

from node-red-docker.

RaymondMouthaan avatar RaymondMouthaan commented on May 24, 2024 2

@DeviousPenguin, have you check https://hub.docker.com/r/raymondmm/node-red/ with its repo found here?

from node-red-docker.

dhallgb avatar dhallgb commented on May 24, 2024 1

That old hypriot image is now causing problems for nodes installation. Some nodes needing to use node-gyp are looking for later gcc versions not in jessie. I tried updating container packages via bash into the container using exec -u 0 but could not get to the correct level of GLIBCXX on stable, tried pinning but gcc-5 removed from testing. The arm64v8 images do have stretch available.
Congrats on v0.19 by the way.

from node-red-docker.

MichaelEFlip avatar MichaelEFlip commented on May 24, 2024 1

Same problem here:
25 Aug 17:13:44 - [info] Node-RED version: v0.19.2
25 Aug 17:13:44 - [info] Node.js version: v8.1.3
25 Aug 17:13:44 - [info] Linux 4.14.52-v7+ arm LE
25 Aug 17:13:45 - [info] Loading palette nodes
25 Aug 17:13:51 - [warn] ------------------------------------------------------
25 Aug 17:13:51 - [warn] [node-red-contrib-ttn/ttn-app] Error: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /data/node_modules/grpc/src/node/extension_binary/node-v57-linux-arm-glibc/grpc_node.node)
25 Aug 17:13:51 - [warn] ------------------------------------------------------

from node-red-docker.

DeviousPenguin avatar DeviousPenguin commented on May 24, 2024 1

@RaymondMouthaan, Thank you, I've just pulled the image, spun it up and it's working great.

from node-red-docker.

rapejim avatar rapejim commented on May 24, 2024 1

No, I don't need use Gpio's of my Raspberry.
I only need the actual version of node.js (or v8.12.0+), but the node-red/node-red-docker:rpi-v8 only have the version v8.3.1 😅 (for this reason I used an official image of Nodejs as a base).

But I was trying to solve your problem with RPi.GPIO warn, 😁

Also, thank you for the info!!

from node-red-docker.

RaymondMouthaan avatar RaymondMouthaan commented on May 24, 2024 1

@rapejim, thanks for solution to fix the warning. I'll apply it to my repo 👍

from node-red-docker.

jthomas avatar jthomas commented on May 24, 2024

I've tested out swapping the base image to that image and the build broke at this line:
https://github.com/node-red/node-red-docker/blob/master/rpi/Dockerfile#L5

Digging around online, looks like we install that package using the python package manager.
https://github.com/alexellis/docker-arm/blob/master/images/armv6/python-gpio-arm/Dockerfile#L6

If I do this, everything works again but the image size has ballooned to 656 MB from 213 MB. The new base image is 540MB. Is this going to be an issue for a device like the Pi?

I've tested re-building with the slim base image for this version (which is 190MB) which reduces the final image size to 458MB. Nowhere near the original size but a bit better.

Does those of you who use RPIs & Node-RED have an opinion on this issue? @knolleary @dceejay

from node-red-docker.

jthomas avatar jthomas commented on May 24, 2024

There is probably some Docker magic you can do with multi-stage builds to strip out the unnecessary build artifacts once the library is installed to shrink the size down again.

I've not got enough experience or time at the moment to investigate this further though.

from node-red-docker.

RaymondMouthaan avatar RaymondMouthaan commented on May 24, 2024

Tried to build FROM arm32v7/node as well and faced the same issue regarding python-rpi.gpio. However applying solution as mentioned in https://github.com/alexellis/docker-arm/blob/master/images/armv6/python-gpio-arm/Dockerfile#L6 did work partly, it builds and installed successfully, but after start of the newly created image, NR still complains about:

Welcome to Node-RED

13 Feb 12:37:21 - [info] Node-RED version: v0.18.2
13 Feb 12:37:21 - [info] Node.js version: v9.5.0
13 Feb 12:37:21 - [info] Linux 4.9.59-v7+ arm LE
13 Feb 12:37:22 - [info] Loading palette nodes
13 Feb 12:37:23 - [warn] Cannot find Pi RPi.GPIO python library
13 Feb 12:37:27 - [warn] ------------------------------------------------------
13 Feb 12:37:27 - [warn] [node-red/rpi-gpio] Warning : Cannot find Pi RPi.GPIO python library
13 Feb 12:37:27 - [warn] ------------------------------------------------------

And indeed i can confirm that the newly create image had a size of 659.9 MB.

During the build I got several other warnings:

Step 9/13 : RUN npm install
 ---> Running in 74b1d982a471
npm WARN deprecated [email protected]: you can use npm install i18next from version 2.0.0
npm WARN deprecated [email protected]: All versions below 4.0.1 of Nodemailer are deprecated. See https://nodemailer.com/status/
npm WARN deprecated [email protected]: Use uuid module instead

> [email protected] install /usr/src/node-red/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.3/bcrypt_lib-v1.0.3-node-v59-linux-arm.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v59 ABI) (falling back to source compile with node-gyp) 
make: Entering directory '/usr/src/node-red/node_modules/bcrypt/build'
  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
In file included from ../../nan/nan.h:192:0,
                 from ../src/bcrypt_node.cc:1:
../../nan/nan_maybe_43_inl.h: In function 'Nan::Maybe<bool> Nan::ForceSet(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)':
../../nan/nan_maybe_43_inl.h:112:73: warning: 'v8::Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)' is deprecated (declared at /usr/src/node-red/.node-gyp/9.5.0/include/node/v8.h:3114): Use CreateDataProperty / DefineOwnProperty [-Wdeprecated-declarations]
   return obj->ForceSet(isolate->GetCurrentContext(), key, value, attribs);
                                                                         ^
  SOLINK_MODULE(target) Release/obj.target/bcrypt_lib.node
  COPY Release/bcrypt_lib.node
  COPY /usr/src/node-red/node_modules/bcrypt/lib/binding/bcrypt_lib.node
  TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory '/usr/src/node-red/node_modules/bcrypt/build'
npm notice created a lockfile as package-lock.json. You should commit this file.

The full Dockerfile I used:

FROM arm32v7/node

# add support for gpio library

#RUN apt-get install python-rpi.gpio

RUN apt-get -q update && \
	apt-get -qy install python-dev python-pip gcc && \
  pip install rpi.gpio

# Home directory for Node-RED application source code.
RUN mkdir -p /usr/src/node-red

# User data directory, contains flows, config and nodes.
RUN mkdir /data

WORKDIR /usr/src/node-red

# Add node-red user so we aren't running as root.
RUN useradd --home-dir /usr/src/node-red --no-create-home node-red \
    && chown -R node-red:node-red /data \
    && chown -R node-red:node-red /usr/src/node-red

USER node-red

# package.json contains Node-RED NPM module and node dependencies
COPY package.json /usr/src/node-red/
RUN npm install

# Cleanup
#RUN apt-get -qy remove python-dev gcc && \
#  rm -rf /var/lib/apt/lists/* && \
#  apt-get -qy clean all

# User configuration directory volume
EXPOSE 1880

# Environment variable holding file path for flows configuration
ENV FLOWS=flows.json
ENV NODE_PATH=/usr/src/node-red/node_modules:/data/node_modules

CMD ["npm", "start", "--", "--userDir", "/data"]

from node-red-docker.

dceejay avatar dceejay commented on May 24, 2024

OK - bit more info... If I install without the GPIO but with the node-red-node-pi-gpiod nodes that can use pigpiod the image is 264 MB (based off 8-slim).

But because this didn't include the build tools it also doesn't include the binary version of bcrypt.

Including gcc g++ make and python (so allow other things that require node-gyp to be installed) - then the size goes up to 390MB.

If we leave pigpiod "outside" then we will need to add some docs to point this out - and note that now port 8888 would need to be open on the host. (It can be restricted - but people will need to read more docs)

from node-red-docker.

RaymondMouthaan avatar RaymondMouthaan commented on May 24, 2024

Well I am not sure if i understand correctly how interaction with gpios on the host pi work, when your solution works.

Does this mean that on the host pi "stuff" needs to be installed and the nodes with NR can interact with it using port 8888?

If some testing is required, just let me know.

Alex Ellis wrote a blog related to gpio on swarm which might be help full: https://blog.alexellis.io/gpio-on-swarm/

from node-red-docker.

dceejay avatar dceejay commented on May 24, 2024

Yes - you need to set pigpiod running on the "host" side... (it's a default part of Raspbian - just not set to run)... sudo pigpiod - this does then open up a port 8888 by default that can then be attached to... - you can limit it with extra parameters to stop it being world accessible but one needs to read the docs for that...
Then the container can connect out to that by using the existing node-red-node-pi-gpiod nodes set to point to the host ip . usually 172.17.0.1 port 8888... I'm proposing we include that node by default in the pi docker build if we can. Plus some docs that say what this post does to start pigpiod.

from node-red-docker.

RaymondMouthaan avatar RaymondMouthaan commented on May 24, 2024

Yes - pigpiod comes with raspbian (stretch) after:
sudo apt-get update & sudo apt-get install pigpiod

Starting it manually :
sudo pigpiod

.. opens port 8888:
tcp6 0 0 :::8888 :::* LISTEN

Reading from its documentation (http://abyz.me.uk/rpi/pigpio/pigpiod.html) there are quit some parameters indeed to limit accessibility.

For example sudo pigpiod -n 192.168.2.101 -p 12345 which starts listening on:
tcp 0 0 0.0.0.0:12345 0.0.0.0:* LISTEN

Using systemctl so that after reboot pigpiod starts at boot time:
to enable the service : sudo systemctl enable pigpiod.service
to start the service : sudo systemctl start pigpiod.service
to stop the service : sudo systemctl stop pigpiod.service

The pigpiod.service file looks like and needs modifications (or is there another way?) regarding the extra parameters :
cat /lib/systemd/system/pigpiod.service

[Unit]
Description=Daemon required to control GPIO pins via pigpio
[Service]
ExecStart=/usr/bin/pigpiod -l
ExecStop=/bin/systemctl kill pigpiod
Type=forking
[Install]
WantedBy=multi-user.target

Not sure if -l should be remove and replace by -n <ip-address-host | hostname-host> and -p .

note: i didn't install python-pigpio python3-pigpio as described in the last section of this page http://abyz.me.uk/rpi/pigpio/download.html , cause i am not sure if we need them.

Your propose sounds great! Implementing this solution avoids the use of --privileged in docker run commands and which is not supported in docker swarm.

from node-red-docker.

dceejay avatar dceejay commented on May 24, 2024

I know it's out of fashion - but one of the easiest ways to start it with parameters is to just add the command line to /etc/rc.local (before the exit line)

/usr/bin/pigpiod all your extra parameters

from node-red-docker.

DeviousPenguin avatar DeviousPenguin commented on May 24, 2024

I'm looking to replace

FROM hypriot/rpi-node:${NODE_VERSION}
in the docker file with one of the images on https://hub.docker.com/r/arm32v7/node/

However, I'm not sure which one do use to replace the hypriot image, is 'stretch' the recommended image? Or would 'slim' be ok? Also by the looks of it NODE_VERSION should be 8? I feel a little overwhelmed with choice here.

I don't need GPIO functionality yet, so if I comment out the
RUN apt-get install python-rpi.gpio
line then it should work ok?

Also would it be worth having a new Dockerfile on github for arm32v7 arm32v7/node/, even if it lacks GPIO functions, then have a different Dockerfile with GPIO extra's installed? They are only small files and for newer users this would make things a million times easier. Thanks

from node-red-docker.

RaymondMouthaan avatar RaymondMouthaan commented on May 24, 2024

@DeviousPenguin, glad I could help 😇

from node-red-docker.

petong avatar petong commented on May 24, 2024

I came across this ticket after opening a PR to get node v10 working on the rpi image:

#111

the tricky part was getting it to build on travis, so I ended up copying in qemu-arm-static from the multiarch debian bootstrap image.

thoughts?

from node-red-docker.

rapejim avatar rapejim commented on May 24, 2024

Tried to build FROM arm32v7/node as well and faced the same issue regarding python-rpi.gpio. However applying solution as mentioned in https://github.com/alexellis/docker-arm/blob/master/images/armv6/python-gpio-arm/Dockerfile#L6 did work partly, it builds and installed successfully, but after start of the newly created image, NR still complains about:

Welcome to Node-RED

13 Feb 12:37:21 - [info] Node-RED version: v0.18.2
13 Feb 12:37:21 - [info] Node.js version: v9.5.0
13 Feb 12:37:21 - [info] Linux 4.9.59-v7+ arm LE
13 Feb 12:37:22 - [info] Loading palette nodes
13 Feb 12:37:23 - [warn] Cannot find Pi RPi.GPIO python library
13 Feb 12:37:27 - [warn] ------------------------------------------------------
13 Feb 12:37:27 - [warn] [node-red/rpi-gpio] Warning : Cannot find Pi RPi.GPIO python library
13 Feb 12:37:27 - [warn] ------------------------------------------------------

And indeed i can confirm that the newly create image had a size of 659.9 MB.

During the build I got several other warnings:

Step 9/13 : RUN npm install
 ---> Running in 74b1d982a471
npm WARN deprecated [email protected]: you can use npm install i18next from version 2.0.0
npm WARN deprecated [email protected]: All versions below 4.0.1 of Nodemailer are deprecated. See https://nodemailer.com/status/
npm WARN deprecated [email protected]: Use uuid module instead

> [email protected] install /usr/src/node-red/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.3/bcrypt_lib-v1.0.3-node-v59-linux-arm.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v59 ABI) (falling back to source compile with node-gyp) 
make: Entering directory '/usr/src/node-red/node_modules/bcrypt/build'
  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
In file included from ../../nan/nan.h:192:0,
                 from ../src/bcrypt_node.cc:1:
../../nan/nan_maybe_43_inl.h: In function 'Nan::Maybe<bool> Nan::ForceSet(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)':
../../nan/nan_maybe_43_inl.h:112:73: warning: 'v8::Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)' is deprecated (declared at /usr/src/node-red/.node-gyp/9.5.0/include/node/v8.h:3114): Use CreateDataProperty / DefineOwnProperty [-Wdeprecated-declarations]
   return obj->ForceSet(isolate->GetCurrentContext(), key, value, attribs);
                                                                         ^
  SOLINK_MODULE(target) Release/obj.target/bcrypt_lib.node
  COPY Release/bcrypt_lib.node
  COPY /usr/src/node-red/node_modules/bcrypt/lib/binding/bcrypt_lib.node
  TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory '/usr/src/node-red/node_modules/bcrypt/build'
npm notice created a lockfile as package-lock.json. You should commit this file.

The full Dockerfile I used:

FROM arm32v7/node

# add support for gpio library

#RUN apt-get install python-rpi.gpio

RUN apt-get -q update && \
	apt-get -qy install python-dev python-pip gcc && \
  pip install rpi.gpio

# Home directory for Node-RED application source code.
RUN mkdir -p /usr/src/node-red

# User data directory, contains flows, config and nodes.
RUN mkdir /data

WORKDIR /usr/src/node-red

# Add node-red user so we aren't running as root.
RUN useradd --home-dir /usr/src/node-red --no-create-home node-red \
    && chown -R node-red:node-red /data \
    && chown -R node-red:node-red /usr/src/node-red

USER node-red

# package.json contains Node-RED NPM module and node dependencies
COPY package.json /usr/src/node-red/
RUN npm install

# Cleanup
#RUN apt-get -qy remove python-dev gcc && \
#  rm -rf /var/lib/apt/lists/* && \
#  apt-get -qy clean all

# User configuration directory volume
EXPOSE 1880

# Environment variable holding file path for flows configuration
ENV FLOWS=flows.json
ENV NODE_PATH=/usr/src/node-red/node_modules:/data/node_modules

CMD ["npm", "start", "--", "--userDir", "/data"]

The error [warn] Cannot find Pi RPi.GPIO python library is caused because the installation of rpi.gpio with pip install rpi.gpio command is used ONLY before change user to "node-red" (when docker are using root), I try it install after "USER node-red" command on dockerfile too, and now I don't have the error.

@RaymondMouthaan can you try it on your dockerfile?

On my Dockerfile I use a official image of Node:

ARG NODE_VERSION=8

FROM node:${NODE_VERSION}-stretch-slim

# add support for gpio library (part 1/2)
RUN apt-get update && apt-get install -y --no-install-recommends python python-dev python-pip python-setuptools build-essential
RUN pip install rpi.gpio

# Clean packages
RUN apt-get clean \
  && rm -rf /var/lib/apt/lists/* 

# Home directory for Node-RED application source code.
RUN mkdir -p /usr/src/node-red

# User data directory, contains flows, config and nodes.
RUN mkdir /data

WORKDIR /usr/src/node-red

# Add node-red user so we aren't running as root.
RUN useradd --home-dir /usr/src/node-red --no-create-home node-red \
    && chown -R node-red:node-red /data \
    && chown -R node-red:node-red /usr/src/node-red

USER node-red

# add support for gpio library (part 2/2)
RUN pip install rpi.gpio

# package.json contains Node-RED NPM module and node dependencies
COPY package.json /usr/src/node-red/
RUN npm install

# User configuration directory volume
EXPOSE 1880

# Environment variable holding file path for flows configuration
ENV FLOWS=flows.json
ENV NODE_PATH=/usr/src/node-red/node_modules:/data/node_modules

CMD ["npm", "start", "--", "--userDir", "/data"]

Using it https://hub.docker.com/r/rapejim/node-red-docker to create a new container... Log of first boot:
image

from node-red-docker.

RaymondMouthaan avatar RaymondMouthaan commented on May 24, 2024

@rapejim, if you want to use the gpio's of the raspberry pi from node-red running within a docker container, I recommend using node-red-node-pi-gpiod, which is a different node made by @dceejay to access the gpio's of a raspberry pi.

Install instructions can be found here and here and it works by running a daemon gpiod on the host node where you have physically hardware connected to the gpio pins. The daemon runs in the background and exposes access to the gpio pins through socket interfaces. More details can be found here.

The node-red docker container with node-red-node-pi-gpiod installed can be deployed on any docker node (in case of a docker swarm) as long as it has network access to your local network, this is an advantage and avoids using --net=host option when deploying the container. In my opinion a far better approach, since it "detaches" the container from the gpio's.

Since node-red/rpi-gpio comes as an base node with node-red, the warning shows up when starting node-red, but can be ignored.

from node-red-docker.

ashish-y avatar ashish-y commented on May 24, 2024

Tried to build FROM arm32v7/node as well and faced the same issue regarding python-rpi.gpio. However applying solution as mentioned in https://github.com/alexellis/docker-arm/blob/master/images/armv6/python-gpio-arm/Dockerfile#L6 did work partly, it builds and installed successfully, but after start of the newly created image, NR still complains about:

Welcome to Node-RED

13 Feb 12:37:21 - [info] Node-RED version: v0.18.2
13 Feb 12:37:21 - [info] Node.js version: v9.5.0
13 Feb 12:37:21 - [info] Linux 4.9.59-v7+ arm LE
13 Feb 12:37:22 - [info] Loading palette nodes
13 Feb 12:37:23 - [warn] Cannot find Pi RPi.GPIO python library
13 Feb 12:37:27 - [warn] ------------------------------------------------------
13 Feb 12:37:27 - [warn] [node-red/rpi-gpio] Warning : Cannot find Pi RPi.GPIO python library
13 Feb 12:37:27 - [warn] ------------------------------------------------------
And indeed i can confirm that the newly create image had a size of 659.9 MB.
During the build I got several other warnings:

Step 9/13 : RUN npm install
 ---> Running in 74b1d982a471
npm WARN deprecated [email protected]: you can use npm install i18next from version 2.0.0
npm WARN deprecated [email protected]: All versions below 4.0.1 of Nodemailer are deprecated. See https://nodemailer.com/status/
npm WARN deprecated [email protected]: Use uuid module instead

> [email protected] install /usr/src/node-red/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.3/bcrypt_lib-v1.0.3-node-v59-linux-arm.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v59 ABI) (falling back to source compile with node-gyp) 
make: Entering directory '/usr/src/node-red/node_modules/bcrypt/build'
  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
In file included from ../../nan/nan.h:192:0,
                 from ../src/bcrypt_node.cc:1:
../../nan/nan_maybe_43_inl.h: In function 'Nan::Maybe<bool> Nan::ForceSet(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)':
../../nan/nan_maybe_43_inl.h:112:73: warning: 'v8::Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)' is deprecated (declared at /usr/src/node-red/.node-gyp/9.5.0/include/node/v8.h:3114): Use CreateDataProperty / DefineOwnProperty [-Wdeprecated-declarations]
   return obj->ForceSet(isolate->GetCurrentContext(), key, value, attribs);
                                                                         ^
  SOLINK_MODULE(target) Release/obj.target/bcrypt_lib.node
  COPY Release/bcrypt_lib.node
  COPY /usr/src/node-red/node_modules/bcrypt/lib/binding/bcrypt_lib.node
  TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory '/usr/src/node-red/node_modules/bcrypt/build'
npm notice created a lockfile as package-lock.json. You should commit this file.

The full Dockerfile I used:

FROM arm32v7/node

# add support for gpio library

#RUN apt-get install python-rpi.gpio

RUN apt-get -q update && \
	apt-get -qy install python-dev python-pip gcc && \
  pip install rpi.gpio

# Home directory for Node-RED application source code.
RUN mkdir -p /usr/src/node-red

# User data directory, contains flows, config and nodes.
RUN mkdir /data

WORKDIR /usr/src/node-red

# Add node-red user so we aren't running as root.
RUN useradd --home-dir /usr/src/node-red --no-create-home node-red \
    && chown -R node-red:node-red /data \
    && chown -R node-red:node-red /usr/src/node-red

USER node-red

# package.json contains Node-RED NPM module and node dependencies
COPY package.json /usr/src/node-red/
RUN npm install

# Cleanup
#RUN apt-get -qy remove python-dev gcc && \
#  rm -rf /var/lib/apt/lists/* && \
#  apt-get -qy clean all

# User configuration directory volume
EXPOSE 1880

# Environment variable holding file path for flows configuration
ENV FLOWS=flows.json
ENV NODE_PATH=/usr/src/node-red/node_modules:/data/node_modules

CMD ["npm", "start", "--", "--userDir", "/data"]

The error [warn] Cannot find Pi RPi.GPIO python library is caused because the installation of rpi.gpio with pip install rpi.gpio command is used ONLY before change user to "node-red" (when docker are using root), I try it install after "USER node-red" command on dockerfile too, and now I don't have the error.

@RaymondMouthaan can you try it on your dockerfile?

On my Dockerfile I use a official image of Node:

ARG NODE_VERSION=8

FROM node:${NODE_VERSION}-stretch-slim

# add support for gpio library (part 1/2)
RUN apt-get update && apt-get install -y --no-install-recommends python python-dev python-pip python-setuptools build-essential
RUN pip install rpi.gpio

# Clean packages
RUN apt-get clean \
  && rm -rf /var/lib/apt/lists/* 

# Home directory for Node-RED application source code.
RUN mkdir -p /usr/src/node-red

# User data directory, contains flows, config and nodes.
RUN mkdir /data

WORKDIR /usr/src/node-red

# Add node-red user so we aren't running as root.
RUN useradd --home-dir /usr/src/node-red --no-create-home node-red \
    && chown -R node-red:node-red /data \
    && chown -R node-red:node-red /usr/src/node-red

USER node-red

# add support for gpio library (part 2/2)
RUN pip install rpi.gpio

# package.json contains Node-RED NPM module and node dependencies
COPY package.json /usr/src/node-red/
RUN npm install

# User configuration directory volume
EXPOSE 1880

# Environment variable holding file path for flows configuration
ENV FLOWS=flows.json
ENV NODE_PATH=/usr/src/node-red/node_modules:/data/node_modules

CMD ["npm", "start", "--", "--userDir", "/data"]

Using it https://hub.docker.com/r/rapejim/node-red-docker to create a new container... Log of first boot:
image

@rapejim
I'm am trying to solve the same issue.
I don't get any error when I run the docker image (build from your Dockerfile) but I'm unable to access RPi GPIO.
Error: No access to /dev/mem. Try running as root

Any pointers?

from node-red-docker.

ashish-y avatar ashish-y commented on May 24, 2024

@rapejim
Never-mind, It was a silly permission issue.
Sorry for the bother.

Thanks

from node-red-docker.

rapejim avatar rapejim commented on May 24, 2024

@ashish-y 👍

from node-red-docker.

dceejay avatar dceejay commented on May 24, 2024

Node-RED 1.0.0 is now available on docker hub - https://hub.docker.com/r/nodered/node-red.

This closes this issue.

There are a few changes to the new release, please read the README for further details.

from node-red-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.