Automating resin/raspberry-pi2-debian build in Gitlab pipeline

Hi,

I am trying to build a simple container for Raspberry Pi model 2 that would run the Nginx server in the reverse proxy mode. I use a private project in the Gitlab.com to store the source code as well as the docker image registry and I would like to automate the build process using the Gitlab CI pipeline.

I can successfully manually build and push the docker image from my windows command line (Docker for Windows is installed), but I am struggling with the Gitlab pipeline integration:

  1. when GitLab Runner is registered under Docker for Windows in shell mode, it builds, but fails to push the image to the registry. This would be Gitlab related probably.

  2. I tried to run the GitLab Runner under Docker installed in Synology NAS, but no luck to set it connecting to the GitLab successfully to even start building.

  3. I installed RancherOS into a virtual machine under Hyper-V and run and registered the GitLab Runner from this, but this fails with error:

    Step 4 : RUN apt-get update && apt-get -qy install curl ca-certificates nginx
    —> Running in e44b8da07ed5
    standard_init_linux.go:175: exec user process caused “exec format error”
    The command ‘/bin/sh -c apt-get update && apt-get -qy install curl ca-certificates nginx’ returned a non-zero code: 1
    ln: failed to create symbolic link ‘/sys/fs/cgroup/systemd/name=systemd’: Operation not permitted

Is there any best practice to build the resin RPi images in GitLab?

My Dockerfile:
FROM resin/raspberry-pi2-debian:latest

# Enable systemd
ENV INITSYSTEM on

ENTRYPOINT []

# Install Nginx
RUN apt-get update && apt-get -qy install curl ca-certificates nginx

# Configure Nginx
RUN rm /etc/nginx/nginx.conf
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80

# Configure Nginx logging
RUN ln -sf /dev/stdout /var/log/nginx/access.log
RUN ln -sf /dev/stderr /var/log/nginx/error.log

# Run Nginx
CMD ["/usr/sbin/nginx"]

My .gitlab_ci.yml just runs: docker build -t $FULL_IMAGE_NAME .

The Gitlab Runner registration under RancherOS in option 3) higher was done this way:

sudo docker run -d --name gitlab-runner --restart unless-stopped --privileged=true -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest
sudo docker exec -it gitlab-runner gitlab-runner register --non-interactive --url "https://gitlab.com/" --registration-token XXXXXXXXXXXXX --description "My RancherOS Gitlab dind runner" --executor "docker" --docker-image gitlab/dind:latest --docker-privileged=true --tag-list "docker" --run-untagged --locked="false"

Thans in advance for your support.

Martin

Hi @martin.jansa

standard_init_linux.go:175: exec user process caused “exec format error” typically indicates mismatched architectures (eg trying to run a container compiled for ARM on amd64, etc). Since the Raspberry Pi 3 is an ARM architecture, you will be unable to run that directly on an amd64 machine without the corresponding hardware virtualization.

Do note that the balenaCloud build service provides a Dockerfile templating system to solve this issue precisely.

I hope this help!