When building in CircleCI using balena-cli v11.36.0 to deploy images some of the services are failing with “Exec format error” (similar to those outlined in building arm containers on x86). This topic is related to issues outlined in emulated-multi-container-build-fails.
When using balena deploy --emulated
the services which are failing are those whose context and dockerfile paths are different from one another. The services which succeed are those which just define the build folder.
Failing service
build:
context: .
dockerfile: ./services/controller/Dockerfile.template
Working service
build: ./services/hardware
The services which fail do not encounter the same issue when built using balena build --emulated
in the service folder.
It seems that I am able to replicate this issue. I’ll trying and narrow it down and open an issue.
1 Like
Okay, I did some more digging. The issue is not related to there being a separate context, but that there is an explicit setting of the dockerfile
property - take a look at issue 1707 for more information.
I’ve tried a bunch of different workarounds, but the only thing that seems to work is to not have the build context separate to the service directory for now.
I’ve linked this thread to the issue so we’ll be able to update you when it’s fixed.
Sorry I can’t be more helpful.
James.
1 Like
We found a sort of work around for our use case.
We created a base image which has a Dockerfile.template
in the root directory of the project. In this base image we copy in files from folders which do not belong to any service.
COPY packages/auth/package.json ./packages/auth/
Then when building a particular service we copy those files from the base image as then there is no context required outside the service folder.
COPY --from=device_main:latest /workspace/packages/build-tools ./packages/build-tools
In order to ensure that the latest base image is created before running the main deploy we made a simple bash script.
mv docker-compose.yml docker-compose.ignore.yml
balena build \
--appName $BALENA_APP_NAME \
--projectName=device \
--logs \
--debug \
--emulated
mv docker-compose.ignore.yml docker-compose.yml
balena deploy $BALENA_APP_NAME \
--projectName=device \
--logs \
--debug \
--build \
--emulated
I hope this helps others who face the same issues that we have been having. Although this is really a work around as part of a work around. Our preference would be to use the Balena arm servers to build the code.
Great news on finding the workaround, we will be looking into the issue as well. Thanks!
1 Like