Pipeline working for runner on windows but not on ubuntu

  • GitLab (Hint: /help): 15.9.8 Self-managed

We are configuring a CI/CD flow to deploy an application on a Raspberry PI. For this we have configured a runner on a ubuntu server. The issue is that we are having problems for this deployment to work because the device’s architecture is arm64. We are getting an error when creating the image that we save in the registry container that doesn’t give us much information to be able to debug:

However, we have noticed that configuring the gitlab Runner on a PC located in our lab, the whole deployment works. We find it very strange since the only difference between both computers is that the PC has Windows as operating system, and the VM is an ubuntu server, but both runners run on Docker, so we don’t think that should matter.

These are the gitlab-ci.yml and the Dockerfile:

release_container_registry:
  stage: build
  tags:
    - SecDelivAutoIoT
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
  script:
    - mkdir -p /kaniko/.docker
    - echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
    - >-
      /kaniko/executor
      --context "${CI_PROJECT_DIR}/"
      --dockerfile "${CI_PROJECT_DIR}/Dockerfile"
      --destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}"
FROM arm64v8/python:3.13-rc-slim-bookworm

WORKDIR /app

COPY helloworld.py .

RUN pip install flask

EXPOSE 3000

CMD [ "python", "app.py" ]

We think that the problem might have something to do with the architecture, as if we use the image python:3.13-rc-slim-bookworm (without arm64v8) it works, but then the app doesn’t run on the Raspberry (because of the architecture). But both runners seem to be identical:

Runner #1271 is the one that works fine. We can see that the gitlab-runner version is not the same (16.0.1 vs 16.1.0) but it doesn’t seem important in this case. The only difference is the Platform, but both are set up to run on docker.

Is there something we are not seeing?

Thanks,
Joel

The problem is that you are trying to build an arm64 image on amd64. When you are building a container from a base image, you’re essentially (trying to) run the base image and make changes on top of that.

This doesn’t work here, because your ubuntu container is not arm.

You can specify the platform on Kaniko, but this only works if the host also supports that architecture.

You’ll have to use buildx for this:

release_container_registry:
  stage: build
  tags:
    - SecDelivAutoIoT
  image: docker:19.03.13
  services:
    - docker:19.03.13-dind
  variables:
    DOCKER_DRIVER: overlay2
    DOCKER_HOST: tcp://localhost:2375
  before_script:
    - docker info
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
    - docker buildx create --use
  script:
    - docker buildx build --platform linux/arm64 --tag "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}" "${CI_PROJECT_DIR}"

As to why it’s working with your windows runner I have no idea, but I think it has something to do that docker on windows is always kind of running in a VM.

1 Like

Thanks for the response!

It is now working thanks to following your suggestion. Just like that it wasn’t working but after a couple of changes it is. This is the job now:

release_container_registry:
  stage: build
  tags:
    - SecDelivAutoIoT
  before_script:
    - docker info
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
    - docker buildx create --use
  script:
    - docker buildx build --platform linux/arm64/v8 --tag "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}" "${CI_PROJECT_DIR}" --push --provenance=false

Glad to see you got it working!

I think you had to make some changes depending on whether you use docker-in-docker or directly mount the docker socket in your runner :slight_smile: