Best Way to Build Balena Images in Gitlab CI

Hello!

I use Balena to deploy software to Jetson TX2 devices. Our Docker images are hosted in GItlab, and I would like a way to build the docker image in the Gitlab CI system. However, I can’t seem to get ROS to install correctly.

My gitlab CI config is this:

image: "docker:19"

docker_image:
  services:
    - docker:dind
  script:
    - cd $CI_PROJECT_DIR/src/payload
    - docker build --file Dockerfile.baseImage --tag CIimage

However, when I run it, I get the following error:

Unpacking ros-melodic-ros-base (1.4.1-0bionic.20200531.064541) ...
[2759](https://gitlab.com/br_consultants/consultants_repo/-/jobs/669069689#L2759)Errors were encountered while processing:
[2760](https://gitlab.com/br_consultants/consultants_repo/-/jobs/669069689#L2760) /tmp/apt-dpkg-install-PLJoTI/051-humanity-icon-theme_0.6.15_all.deb
[2761](https://gitlab.com/br_consultants/consultants_repo/-/jobs/669069689#L2761)E: Sub-process /usr/bin/dpkg returned an error code (1)
[2762](https://gitlab.com/br_consultants/consultants_repo/-/jobs/669069689#L2762)The command '/bin/sh -c apt-get install -y ros-melodic-ros-base' returned a non-zero code: 100
[2764](https://gitlab.com/br_consultants/consultants_repo/-/jobs/669069689#L2764)ERROR: Job failed: exit code 100

I’ve currently been using the FROM balenalib/aarch64-ubuntu:bionic image and I’ve surrounded my installation calls with the RUN [ “cross-build-start” ] and RUN [ “cross-build-end” ] commands.

Which I thought would handle the emulation. Any advice on what I’m doing wrong?

Hi @keenanbedrock,

I build a bunch of images from Balena base images using gitlab CI without too much incident. Take a look at my gitlab CI config[1]. Of particular interest I think are the environment variables which I set near the top.

Be careful if you are using gitlab’s shared runners that qemu-based emulated builds seem to be much slower and use a lot more ram. I’ve also managed to run the builder out of disk space before, which is why I have my own runners.

Hope that helps.
James.

1: https://gitlab.com/jimsy/balena-erlang/-/blob/master/.gitlab-ci.yml

Thanks yeah that was super helpful!