Docker, build your custom image, entry point in error

Hello, I try to create a custom docker image.
I followed the documentation well, but I can't launch the container. It doesn't find the entry point (see log below)
I have according the doc. modified the package.json file to include the scripts section
(the documentation is not precise enough on the syntax for me) See the snapshot below.

Could you please tell me where I'm doing things wrong? Thanks in advance.

Log:

Dockerfile:
image
package.json
image

I have used the files and instructions here - node-red-docker/docker-custom at master · node-red/node-red-docker · GitHub - to successfully build and deploy a docker image.

It looks like a lot of work to me :thinking:
I'll dive into it tomorrow if I have enough time. Thanks for the pointer to this link.

I was a bit overwhelmed as well at first, but in essence all you need to do is put your flow file into your downloaded copy of that repository, put your dependencies in the package.json file and run the build shell script. I used the alpine Linux one as you end up with a smaller image, and it 'just worked'.

I admit that I don't immediately understand why you are getting that error.
I have checked that folder for my container and it contains red.js:

bash-5.0$ pwd
/usr/src/node-red/node_modules/node-red
bash-5.0$ ls
CHANGELOG.md  LICENSE       README.md     bin           lib           package.json  red.js        settings.js
bash-5.0$ 

... but I noted that my package.json doesn't contain the start command.

So here a copy of my package.json (I have removed 2 dependencies from it).

{
    "name": "node-red-mydrive-ctrl",
    "description": "Node-RED My-Drive Controller",
    "version": "0.0.1",
    "dependencies": {
        "node-red-node-daemon": "0.2.1",
        "node-red-dashboard": "2.29.0"
    },
    "node-red": {
        "settings": {
            "flowFile": "flows.json",
            "credentialsFile": "flows_cred.json"
        }
    }
}

So can you update your package.json to make it more like mine (or test in the first place with my package.json) and check if that not fixes the problem ?

Here is the result, I used your file directly.
It doesn't work.
In the doc, it is well written that it is necessary to put a section scripts ?!
I can't even go into the container because it is stopped.

image

Maybe this is due to the use of Portainer.io to create the containers.
(Or the architecture of the orangePi is not adapted)

Files used:
Dockerfile
image
Package.json
image

Command used:

Tested with no luck. It seems that it is not the same processor architecture.
(Orange Pi PC - Chinese Raspberry Pi clone with Allwinner ARMv7 processor)

So I changed in the file Dockerfile.custom amd64 by arm or arm64 or armhf but it is not better.

I also tried with the parameter --build-arg ARCH=arm32v7

Indeed (my fault). It is expecting that the packages are installed under /data folder.

The following Dockerfile should work:

FROM nodered/node-red

COPY package.json /data/
# The following command will build all the nodes specified in the package.json that is copied
# in previous command.
RUN  cd /data; npm install --unsafe-perm --no-update-notifier --no-fund --only=production

If that doesn't work then you can add an ENTRYPOINT to explicitly run the start specifying the /data folder as userDir.

FROM nodered/node-red:1.2.9-12

COPY package.json /data/
# The following command will build all the nodes specified in the package.json that is copied
# in previous command.
RUN  cd /data; npm install --unsafe-perm --no-update-notifier --no-fund --only=production

ENTRYPOINT npm start --  --userDir /data

Yes, that's it, it works as desired. :v:
The customised container works.
Variables go well in the directory, flows are well recognized, packages are well installed. It's cool,It's cool, it's pleasant.

The next step is coming.
Can I start a docker pull (upgrade) automatically from a live flow NR when there will be a new version that I will have dropped on dockerhub ?
I will investigate this now.
The never ending story, it's fun :slightly_smiling_face:

1 Like

I think that that statement is not true.

The problem was that the docker command COPY package.json . that we used earlier is overwriting the existing node-red package.json that is specifying the start script. So that is the reason it couldn't find the start script.

So by copying it to another folder (e.g. to the /data folder) we fixed the problem.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.