@Ciantic, they key error is probably:
[Build] main /bin/sh: Invalid ELF image for this architecture
Which usually indicates a CPU architecture mismatch, such as Intel vs ARM, 32 bit vs 64 bit. It is happening at Dockerfile step 5/13, "npm install --unsafe-perm --production"
.
Given the following output:
[Info] Building for aarch64/raspberrypi4-64
[Info] Installing qemu for aarch64 emulation...
[Debug] Resolving services with [raspberrypi4-64|aarch64]
I gather that you project is for the RPi 4, 64 bits. The base image is however for the RPi 3, 32 bits:
[Build] main Step 1/13 : FROM balenalib/raspberrypi3-node:8-build AS base
I don’t know if this image mismatch is necessarily a problem – I actually seem to remember that the RPi3 image works fine on the RPi4. However, it might be worth trying an RPi 4 base image, balenalib/raspberrypi4-64-node
.
Also: balena deploy
, as used, is building the image using your laptop (dev machine) Docker installation. To narrow down the issue, try also building without emulation on balenaCloud builders (we have ARM servers) with balena push
, and/or building on a real RPi4 device on your desk. To test the latter, flash a development image and place the device in local mode, then run something like:
balena deploy myApp --logs --source . --dockerPort 2375 --dockerHost 192.168.1.2
replacing 192.168.1.2
with your device’s IP address.
If building without emulation works, the problem may be that QEMU is simply not up to the task; it is known to fail on some compilation tasks or other tasks, which npm install
may be triggering. Try also running some other binary executables (other than npm
) to rule this out – starting with something like /bin/sh -c 'echo hello world'
.