Simplest app fails to build for balena fin

I have created an application with a simple Dockerfile.template

FROM balenalib/%%BALENA_MACHINE_NAME%%-alpine-python:3.7-build as build
RUN echo "Hello"
COPY idle.sh idle.sh
CMD ["/bin/bash","-c",". idle.sh"]

The target device is a fincm3 in an application with ID 1497516 named fins-to-the-left. I try to build using:

balena build -a fins-to-the-left

and it fails

balena-test> balena build -a fins-to-the-left
[Info]    Creating default composition with source: /Users/ff/consulting/NSR/dev/balena-test
[Info]    Building for armv7hf/fincm3
[Info]    Docker Desktop detected (daemon architecture: "x86_64")
[Info]      Docker itself will determine and enable architecture emulation if required,
[Info]      without balena-cli intervention and regardless of the --emulated option.
[Build]   Built 1 service in 0:01
[Build]   main [=============>       ]  66% Step 2/3: standard_init_linux.go:211: exec user process caused "no such file or directory"
[Error]   Build failed
The command '/bin/sh -c echo "Hello"' returned a non-zero code: 1

Additional information may be available by setting a DEBUG=1 environment
variable: "set DEBUG=1" on a Windows command prompt, or "export DEBUG=1"
on Linux or macOS.

If you need help, don't hesitate in contacting our support forums at
https://forums.balena.io

For CLI bug reports or feature requests, have a look at the GitHub issues or

Removing the offending RUN command, I can build and the run the image, and then logging into the container I can see

bash-5.0# sh -c echo hello
bash: /bin/sh: /bin/sh.real\nbalena-info\nrm: bad interpreter: No such file or directory

bash-5.0# cat /bin/sh
#!/bin/sh.real\nbalena-info\nrm -f /bin/sh\ncp /bin/sh.real /bin/sh\n/bin/sh "$@"

seems /bin/sh is broken?

Hi,

From the logs, your docker daemon architecture is x86_64 while the fincm3 is armv7hf so you should add --emulated option to your balena build command and it will run an emulated build using qemu on your development machine (more details can be found in our docs here https://www.balena.io/docs/learn/deploy/deployment/#--emulated--e-1).

Regarding the /bin/sh issue, it’s an old issue that we fixed so can you please re-pull the image and try again? I just manually run balenalib/fincm3-alpine-python:3.7-build and have no issue with it.

Hi,

Thanks. Pulling a new image fixed the issue.

The --emulated switch has been confusing to me. When I’ve had issues, I have found no difference running w/ --emulated or not and in previous discussions my understanding was that the --emulated option was superfluous. Note the comment output by the build:

[Info]    Docker Desktop detected (daemon architecture: "x86_64")
[Info]      Docker itself will determine and enable architecture emulation if required,
[Info]      without balena-cli intervention and regardless of the --emulated option.

What’s your interpretation of this comment?

As a note, I was using this super simple project with balena build just because it manifested the issue and was faster to experiment with than balena push with the real project. But now the real project works - hmm, was there a bad image cached even with the push?

In any case, we’re off and running - not sure what changed, but it works.

Thanks for your help.

The build output comment you referred to is basically saying that we try to detect and override for emulated where we can but it may not happen in all cases. It’s probably best to pass the flag to be explicit just in case the need for emulation is not automatically detected.

@alanb128 Thanks that makes sense.

May I also ask a very basic question? how do I find the appropriate architecture for a device. For example, the deviceType for my app is clearly fincm3 but if I want to build w/o the -a switch I have to provide both deviceType and architecture, which assumes a device type can have multiple architectures?

Sure, you can use this page: https://www.balena.io/docs/reference/base-images/devicetypes/ to see devices and architecture types. I don’t think any device type has multiple architectures though.

1 Like