Docker image problem on Bitbucket

Hi devzone,

I'm working on the nRF54L05, having an application and the mcuboot generated correctly on my host computer.
Now we want to generate the binaries on Bitbucket pipelines. I tried to follow the "nRF Connect SDK toolchain Docker image" section (docs.nordicsemi.com/.../README.html), first locally on my computer and then on Bitbucket.

LOCALLY:
Using the command proposed on the guide I was getting the same error all the time, and the container was never created:

docker run -ti ghcr.io/nrfconnect/sdk-nrf-toolchain:v3.0.2 -v /dev:/dev --privileged -e ACCEPT_JLINK_LICENSE=1 bash
Error:
--privileged: line 1: /dev:/dev: No such file or directory

After some investigation I found the command was wrong. Maybe an experimented docker user can find the error fast but for me, without much docker experience, it was difficult to see. This is only a suggestion to fix this typo.

Right command:
docker run -ti -v /dev:/dev --privileged -e ACCEPT_JLINK_LICENSE=1 ghcr.io/nrfconnect/sdk-nrf-toolchain:v3.0.2 bash


Now the docker container is running and I can see:
root@e59e2b371140:~# west --version
West version: v1.2.0


But executing "echo $ZEPHYR_BASE" I don't have any output. I think that's why I cannot build my application either (previously mounted to /home).
root@d19f76caefd7:/home# west build -b nrf54l15dk/nrf54l05/cpuapp -p always
usage: west [-h] [-z ZEPHYR_BASE] [-v] [-V] <command> ...
west: unknown command "build"; do you need to run this inside a workspace?
root@d19f76caefd7:/home# west update
FATAL ERROR: no west workspace found from "/home"; "west update" requires one.
Things to try:
  - Change directory to somewhere inside a west workspace and retry.
  - Set ZEPHYR_BASE to a zephyr repository path in a west workspace.
  - Run "west init" to set up a workspace here.
  - Run "west init -h" for additional information.


Question 1. How can I build my application locally using this docker image? I'm sure I'm missing something.

IN CI:
My bitbucket-pipeliens.yml is:

image: ghcr.io/nrfconnect/sdk-nrf-toolchain:v3.0.2
pipelines:
  default:
    - step:
        name: Build
        script:
          - export ACCEPT_JLINK_LICENSE=1
          - west update
          - echo "Running west --version in the container"
          - west --version


This method is not working because the pipeline is blocked printing: input. Please use y/n
This means the "export ACCEPT_JLINK_LICENSE=1" is not working. I tried adding the ACCEPT_JLINK_LICENSE on the "Repository Settings->Pipelines->Repository variables" and "- echo 'y' | west update" but the result is the same.

Question2. How can I use this docker image on bitbucket pipeline?

Thanks in advance.

Parents
  • Hello!
    I was trying to build my firmware with the help of bitbucket pipelines too with no success. Setting the ACCEPT_JLINK_LICENSE=1 repository variable does not help.
    I was able to find a workaround with the help of Gemini. The workaround uses a generic docker image, that is provided by bitbucket. And inside this docker image you launch Nordic's docker image and pass it the required parameter. With the help of the workaround I am now able to build the firmware on bitbucket.
    Here is the part of my bitbucket-pipelines.yml:

    # Use Atlassian's default CI runner instead of Nordic's
    image: atlassian/default-image:4
    
    # Override the default 1GB Docker limit and give it 6GB for compilation
    definitions:
      services:
        docker:
          memory: 6144
    
    pipelines:
      branches:
        dev:
          - step:
              name: Build nRF54L15 Firmware
              size: 2x 
              # Enable Docker inside the pipeline
              services:
                - docker
              script:
                # 1. WRITE THE BUILD SCRIPT
                # We generate a script file dynamically. This script will run INSIDE the Nordic container.
                - |
                  cat << 'EOF' > compile.sh
                  #!/bin/bash
                  set -e
    
                  # Fix Git dubious ownership error
                  git config --global --add safe.directory '*'
                  
                  # Initialize and Update T2 Workspace
                  west init -l <you project name>
                  west update --narrow
                  
                  cd <your project folder>
                  
                  # Here are your west commands to build the firmware and create build artifacts
                  EOF
    
                - chmod +x compile.sh
    
                # 2. RUN DOCKER-IN-DOCKER
                - >
                  docker run --rm 
                  -e ACCEPT_JLINK_LICENSE=1 
                  -v $(pwd):/workdir/<your project folder> 
                  -w /workdir 
                  ghcr.io/nrfconnect/sdk-nrf-toolchain:v3.2.4 
                  ./<your project folder>/compile.sh
    
                # 3. PUBLISH TO BITBUCKET DOWNLOADS
                # The compiled files are left in the workspace and uploaded here.
                - pipe: atlassian/bitbucket-upload-file:0.7.5
                  variables:
                    ATLASSIAN_ACCOUNT_EMAIL: $ATLASSIAN_ACCOUNT_EMAIL
                    ATLASSIAN_API_TOKEN: $ATLASSIAN_API_TOKEN
                    FILENAME: 'release_artifacts/*'
    
              # 4. ATTACH TO PIPELINE
              artifacts:
                - release_artifacts/**

  • Hi,

    I don't know much about Bitbucket, but I am not too keen of your solution here. It feels to me that you shouldn't need to do any DinD (Docker in Docker) inside the pipeline just to set an environment variable.

    Also having a script directly written inside the .yml file doesn't seem great for maintenance.

    It may work for quick testing, but I can't really recommend your solution for a proper production environment as it will waste quite a lot of resource.

    Best regards,

    Simon D-M

  • I also don't like the solution. I have created the topic on the Atlassian forum. But nobody responds. So it is the best working solution, that I have.
    As for the script directly inside the .yml. Yes, probably the best way is to place a .sh file directly to the repository instead.

Reply Children
No Data
Related