Docker build fail

Actually Raspberry pi 4, but there doesn’t seem to be a tag for that.

I’m trying to build an image with both python and node. Here’s a simple dockerfile.template:

FROM balenalib/%%BALENA_MACHINE_NAME%%-ubuntu-python:3.7-build as build

RUN curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
RUN apt-get install nodejs

RUN echo "Hello"
COPY idle.sh idle.sh
CMD ["/bin/bash","-c",". idle.sh"]

If I skip lines 2 and 3, and execute them after logging into the container from the web terminal, they run fine and node 12 installs. However, the build fails when running it using balena build.

[Debug]   Prepared tasks; building...
[Build]   main Step 1/6 : FROM balenalib/raspberrypi4-64-ubuntu-python:3.7-build as build
[Build]   main  ---> 9267040b7ec9
[Build]   main Step 2/6 : RUN curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
[Build]   main  ---> Using cache
[Build]   main  ---> b82bf1d13038
[Build]   main Step 3/6 : RUN apt-get install nodejs
[Build]   main  ---> Running in 2e62ade8f100
[Build]   main Reading package lists...
[Build]   main Building dependency tree...
[Build]   main Reading state information...
[Build]   main E: Unable to locate package nodejs
[Build]   Built 1 service in 0:01
[Error]   Build failed
The command '/bin/sh -c apt-get install nodejs' returned a non-zero code: 100
Error: The command '/bin/sh -c apt-get install nodejs' returned a non-zero code: 100
    at Stream.<anonymous> (/usr/local/lib/node_modules/balena-cli/node_modules/resin-docker-build/build/builder.js:178:23)

What am I missing?

Hi,

Please append the -y flag to the end of RUN apt-get install nodejs. The build is failing because the apt-get command prompts for a confirmation from the the user to proceed. The flag allows it to proceed without prompting the user. This is why it fails with a non-zero code.

Cheers,
Carlo

Thanks for the response. Same result:

[Build]   main Step 3/6 : RUN apt-get install -y nodejs
[Build]   main  ---> Running in 9112a482f495
[Build]   main Reading package lists...
[Build]   main Building dependency tree...
[Build]   main Reading state information...
[Build]   main E: Unable to locate package nodejs
[Build]   Built 1 service in 0:02
[Error]   Build failed
The command '/bin/sh -c apt-get install -y nodejs' returned a non-zero code: 100
Error: The command '/bin/sh -c apt-get install -y nodejs' returned a non-zero code: 100
    at Stream.<anonymous> (/usr/local/lib/node_modules/balena-cli/node_modules/resin-docker-build/build/builder.js:178:23)
    at Stream.stream.write (/usr/local/lib/node_modules/balena-cli/node_modules/through/index.js:26:11)
    at Stream.ondata (internal/streams/legacy.js:19:31)

The error remains the same: “Unable to locate package nodejs”.

Hello,
Can you please try editing the line RUN curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - or any line before it, just to invalidate the cache. (Add a space after curl for example).

Hi @zvin That may have done it - actually, I had done some experiments going backwards, that is starting from a node image and adding python, which worked and got my project going. Now when I went back to starting with a python image and adding node it seems to have worked w/o getting those errors.

Glad to hear that worked. :slight_smile:

Also, thanks, I’ll add a tag for Raspberry Pi 4 for future use.