|
| 1 | +.. _nrf_toolchain_docker_image: |
| 2 | + |
| 3 | +|NCS| toolchain Docker image |
| 4 | +############################ |
| 5 | + |
| 6 | +.. contents:: |
| 7 | + :local: |
| 8 | + :depth: 2 |
| 9 | + |
| 10 | +The image is based on Linux - Ubuntu 22.04 Docker image with the following additional tools: |
| 11 | + |
| 12 | +* Git |
| 13 | +* `nRF Util`_ with following commands: |
| 14 | + |
| 15 | + * ``toolchain-manager`` |
| 16 | + * ``device`` |
| 17 | + |
| 18 | +* |NCS| toolchain bundle |
| 19 | +* JLink |jlink_ver| (installation requires accepting SEGGER License) |
| 20 | + |
| 21 | +Building image |
| 22 | +************** |
| 23 | + |
| 24 | +To build a Docker image, you have to provide a ``VERSION`` argument containing the ID of the Linux toolchain bundle you want to install. |
| 25 | +You can use `print_toolchain_checksum.sh`_ to get ID proper for your |NCS| revision. |
| 26 | + |
| 27 | +.. code-block:: shell |
| 28 | +
|
| 29 | + TOOLCHAIN_ID=$(../print_toolchain_checksum.sh) |
| 30 | + docker build --build-arg VERSION=$TOOLCHAIN_ID |
| 31 | +
|
| 32 | +Accepting JLink license |
| 33 | +*********************** |
| 34 | + |
| 35 | +To install and use JLink software you have to accept `JLink License Agreement`_. |
| 36 | + |
| 37 | +If the container is run in an interactive mode, you will be asked to accept the license at the start of the container. |
| 38 | + |
| 39 | +You can also start the container with the ``ACCEPT_JLINK_LICENSE=1`` environment variable, and JLink will be installed without prompting. |
| 40 | + |
| 41 | +During post installation steps, JLink configures ``udev`` roles. |
| 42 | +This operation requires running a container with the ``--privileged`` flag to grant permissions needed for the container. |
| 43 | + |
| 44 | +Running container |
| 45 | +***************** |
| 46 | + |
| 47 | +Toolchain environment variables are set only in Bash sessions. |
| 48 | +Outside the Bash session, these variables are not set, and tools delivered in the toolchain bundle cannot be found on the path. |
| 49 | +|NCS| toolchain image uses ``bash`` command as entry point. |
| 50 | +If the entry point is not overwritten, you can start your Docker container in both interactive and non-interactive mode. |
| 51 | + |
| 52 | +Locally |
| 53 | +======= |
| 54 | + |
| 55 | +To run the |NCS| toolchain container to build and flash HEX files, run the following command. |
| 56 | + |
| 57 | +.. code-block:: none |
| 58 | +
|
| 59 | + docker run -ti ghcr.io/nrfconnect/sdk-nrf-toolchain:<TAG> -v /dev:/dev --privileged -e ACCEPT_JLINK_LICENSE=1 bash |
| 60 | +
|
| 61 | +.. tip:: |
| 62 | + |
| 63 | + You can also add the ``-v <PATH-TO-NCS-PROJECT-ON-DOCKER-HOST>:/ncs`` argument to the ``docker run`` command to mount the |NCS| project to the container. |
| 64 | + In such cases, you might encounter issues with repositories, ownership, and west project configuration. |
| 65 | + To resolve them, perform the following: |
| 66 | + |
| 67 | + * Run the ``git config --global --add safe.directory '*'`` command to mark mounted git repositories as trusted. |
| 68 | + * Run the ``west update`` command to import west commands delivered in the |NCS| project (for example, ``west build``) |
| 69 | + * Add ``--pristine`` argument to ``west build`` command to avoid path mismatch issues. |
| 70 | + |
| 71 | +In CI |
| 72 | +===== |
| 73 | + |
| 74 | +CI systems usually run the Docker container in detached mode and can override the default entry point and command. |
| 75 | +However, it is still possible to use the |NCS| toolchain images in pipelines. |
| 76 | + |
| 77 | +GitHub Actions |
| 78 | +-------------- |
| 79 | + |
| 80 | +GitHub action starts container with overwritten default entry point. That means you have to set ``bash`` as a default shell to load all required environment variables. |
| 81 | + |
| 82 | +If the container is started with the ``ACCEPT_JLINK_LICENSE`` env variable set to ``1``, JLink will be installed just before the first bash command is executed. |
| 83 | + |
| 84 | +Example job configuration: |
| 85 | + |
| 86 | +.. code-block:: yaml |
| 87 | +
|
| 88 | + jobs: |
| 89 | + build-in-docker: |
| 90 | + runs-on: ubuntu-22.04 |
| 91 | + container: |
| 92 | + image: ghcr.io/nrfconnect/sdk-nrf-toolchain:<TAG> # steps in this job are executed inside sdk-nrf-toolchain container |
| 93 | + env: |
| 94 | + ACCEPT_JLINK_LICENSE: 1 # set if you want to install JLink |
| 95 | + defaults: |
| 96 | + run: |
| 97 | + shell: bash # It is required to set `bash` as default shell |
| 98 | + steps: |
| 99 | + - name: Run command in NCS toolchain environment |
| 100 | + run: "west --version" # This command is executed in bash shell `docker exec <container> bash -c west --version` |
| 101 | + # It will also install JLink if ACCEPT_JLINK_LICENSE is set to 1 |
0 commit comments