├── .github └── workflows │ ├── publish-docker.yaml │ └── verify.yaml ├── Dockerfile ├── LICENSE ├── README.md └── diagram.png /.github/workflows/publish-docker.yaml: -------------------------------------------------------------------------------- 1 | name: Publish Docker 2 | 3 | on: 4 | push: 5 | branches: 6 | - saga 7 | schedule: 8 | - cron: "0 0 * * *" 9 | 10 | env: 11 | DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} 12 | 13 | jobs: 14 | build: 15 | strategy: 16 | matrix: 17 | ncs_branch: 18 | - main 19 | - v1.9-branch 20 | - v1.8-branch 21 | - v1.7-branch 22 | - v1.6-branch 23 | - v1.5-branch 24 | - v1.4-branch 25 | runs-on: ubuntu-latest 26 | steps: 27 | - uses: actions/checkout@v2 28 | 29 | - name: Build image 30 | run: | 31 | docker build -t coderbyheart/fw-nrfconnect-nrf-docker:${{ matrix.ncs_branch }} \ 32 | --build-arg sdk_nrf_revision=${{ matrix.ncs_branch }} . 33 | 34 | - name: Initialize sdk-nrf 35 | run: | 36 | docker run --rm -v ${PWD}:/workdir/project \ 37 | coderbyheart/fw-nrfconnect-nrf-docker:${{ matrix.ncs_branch }} \ 38 | west init -m https://github.com/nrfconnect/sdk-nrf --mr ${{ matrix.ncs_branch }} 39 | 40 | - name: Update west dependencies 41 | run: | 42 | docker run --rm -v ${PWD}:/workdir/project \ 43 | coderbyheart/fw-nrfconnect-nrf-docker:${{ matrix.ncs_branch }} \ 44 | west update --narrow -o=--depth=1 45 | 46 | - name: Build asset_tracker application 47 | # Removed in 1.9 48 | if: matrix.ncs_branch != 'main' && matrix.ncs_branch != 'v1.9-branch' 49 | run: | 50 | docker run --rm -v ${PWD}:/workdir/project \ 51 | -w /workdir/project/nrf/applications/asset_tracker \ 52 | coderbyheart/fw-nrfconnect-nrf-docker:${{ matrix.ncs_branch }} \ 53 | west build -b nrf9160dk_nrf9160ns 54 | 55 | - uses: actions/upload-artifact@v2 56 | with: 57 | name: asset_tracker-${{ matrix.ncs_branch }} 58 | path: | 59 | nrf/applications/asset_tracker/build/zephyr/merged.hex 60 | nrf/applications/asset_tracker/build/zephyr/app_update.bin 61 | 62 | - name: Build asset_tracker_v2 application 63 | # Not available in 1.4, and needs configuration in 1.5 64 | if: matrix.ncs_branch != 'v1.4-branch' && matrix.ncs_branch != 'v1.5-branch' 65 | run: | 66 | docker run --rm -v ${PWD}:/workdir/project \ 67 | -w /workdir/project/nrf/applications/asset_tracker_v2 \ 68 | coderbyheart/fw-nrfconnect-nrf-docker:${{ matrix.ncs_branch }} \ 69 | west build -b nrf9160dk_nrf9160ns 70 | 71 | - uses: actions/upload-artifact@v2 72 | if: matrix.ncs_branch != 'v1.4-branch' && matrix.ncs_branch != 'v1.5-branch' 73 | with: 74 | name: asset_tracker_v2-${{ matrix.ncs_branch }} 75 | path: | 76 | nrf/applications/asset_tracker_v2/build/zephyr/merged.hex 77 | nrf/applications/asset_tracker_v2/build/zephyr/app_update.bin 78 | 79 | - name: Publish image 80 | run: | 81 | cd nrf 82 | docker login -u coderbyheart -p $DOCKER_PASSWORD 83 | docker images 84 | docker push coderbyheart/fw-nrfconnect-nrf-docker:${{ matrix.ncs_branch }} 85 | -------------------------------------------------------------------------------- /.github/workflows/verify.yaml: -------------------------------------------------------------------------------- 1 | name: Verify Dockerfile 2 | 3 | on: pull_request 4 | 5 | jobs: 6 | build: 7 | strategy: 8 | matrix: 9 | ncs_branch: 10 | - main 11 | - v1.9-branch 12 | - v1.8-branch 13 | - v1.7-branch 14 | - v1.6-branch 15 | - v1.5-branch 16 | - v1.4-branch 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v2 20 | 21 | - name: Build image 22 | run: | 23 | docker build -t coderbyheart/fw-nrfconnect-nrf-docker:${{ matrix.ncs_branch }} \ 24 | --build-arg sdk_nrf_revision=${{ matrix.ncs_branch }} . 25 | 26 | - name: Initialize sdk-nrf 27 | run: | 28 | docker run --rm -v ${PWD}:/workdir/project \ 29 | coderbyheart/fw-nrfconnect-nrf-docker:${{ matrix.ncs_branch }} \ 30 | west init -m https://github.com/nrfconnect/sdk-nrf --mr ${{ matrix.ncs_branch }} 31 | 32 | - name: Update west dependencies 33 | run: | 34 | docker run --rm -v ${PWD}:/workdir/project \ 35 | coderbyheart/fw-nrfconnect-nrf-docker:${{ matrix.ncs_branch }} \ 36 | west update --narrow -o=--depth=1 37 | 38 | - name: Build asset_tracker application 39 | # Removed in 1.9 40 | if: matrix.ncs_branch != 'main' && matrix.ncs_branch != 'v1.9-branch' 41 | run: | 42 | docker run --rm -v ${PWD}:/workdir/project \ 43 | -w /workdir/project/nrf/applications/asset_tracker \ 44 | coderbyheart/fw-nrfconnect-nrf-docker:${{ matrix.ncs_branch }} \ 45 | west build -b nrf9160dk_nrf9160ns 46 | 47 | - uses: actions/upload-artifact@v2 48 | with: 49 | name: asset_tracker-${{ matrix.ncs_branch }} 50 | path: | 51 | nrf/applications/asset_tracker/build/zephyr/merged.hex 52 | nrf/applications/asset_tracker/build/zephyr/app_update.bin 53 | 54 | - name: Build asset_tracker_v2 application 55 | # Not available in 1.4, and needs configuration in 1.5 56 | if: matrix.ncs_branch != 'v1.4-branch' && matrix.ncs_branch != 'v1.5-branch' 57 | run: | 58 | docker run --rm -v ${PWD}:/workdir/project \ 59 | -w /workdir/project/nrf/applications/asset_tracker_v2 \ 60 | coderbyheart/fw-nrfconnect-nrf-docker:${{ matrix.ncs_branch }} \ 61 | west build -b nrf9160dk_nrf9160ns 62 | 63 | - uses: actions/upload-artifact@v2 64 | if: matrix.ncs_branch != 'v1.4-branch' && matrix.ncs_branch != 'v1.5-branch' 65 | with: 66 | name: asset_tracker_v2-${{ matrix.ncs_branch }} 67 | path: | 68 | nrf/applications/asset_tracker_v2/build/zephyr/merged.hex 69 | nrf/applications/asset_tracker_v2/build/zephyr/app_update.bin 70 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Base image which contains global dependencies 2 | FROM ubuntu:20.04 as base 3 | WORKDIR /workdir 4 | 5 | # System dependencies 6 | ARG arch=amd64 7 | RUN mkdir /workdir/project && \ 8 | mkdir /workdir/.cache && \ 9 | apt-get -y update && \ 10 | apt-get -y upgrade && \ 11 | apt-get -y install \ 12 | wget \ 13 | python3-pip \ 14 | ninja-build \ 15 | gperf \ 16 | git \ 17 | unzip \ 18 | python3-setuptools \ 19 | libncurses5 libncurses5-dev \ 20 | libyaml-dev libfdt1 \ 21 | libusb-1.0-0-dev udev \ 22 | device-tree-compiler=1.5.1-1 \ 23 | ruby && \ 24 | apt-get -y clean && apt-get -y autoremove && \ 25 | # GCC ARM Embed Toolchain 26 | echo "Target architecture: $arch" && \ 27 | case $arch in \ 28 | "amd64") \ 29 | NCLT_URL="https://www.nordicsemi.com/-/media/Software-and-other-downloads/Desktop-software/nRF-command-line-tools/sw/Versions-10-x-x/10-15-0/nrf-command-line-tools-10.15.0_amd.zip" \ 30 | ARM_URL="https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2?revision=108bd959-44bd-4619-9c19-26187abf5225&la=en&hash=E788CE92E5DFD64B2A8C246BBA91A249CB8E2D2D" \ 31 | ;; \ 32 | "arm64") \ 33 | NCLT_URL="" \ 34 | ARM_URL="https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-aarch64-linux.tar.bz2?revision=4583ce78-e7e7-459a-ad9f-bff8e94839f1&hash=CF9005177C5564B8A88F71AF541808EB" \ 35 | ;; \ 36 | *) \ 37 | echo "Unsupported TARGETARCH: \"$TARGETARCH\"" >&2 && \ 38 | exit 1 ;; \ 39 | esac && \ 40 | wget -qO - "${ARM_URL}" | tar xj && \ 41 | # Nordic command line tools 42 | # Releases: https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Command-Line-Tools/Download 43 | # Doesn't exist for arm64, but not necessary for building 44 | if [ ! -z "$NCLT_URL" ]; then \ 45 | mkdir tmp && cd tmp && \ 46 | wget -q "${NCLT_URL}" && \ 47 | unzip nrf-command-line-tools-*.zip && \ 48 | tar xzf nrf-command-line-tools-*.tar.gz && \ 49 | dpkg -i *.deb && \ 50 | cd .. && rm -rf tmp ; \ 51 | else \ 52 | echo "Skipping nRF Command Line Tools (not available for $arch)" ; \ 53 | fi && \ 54 | # Latest PIP & Python dependencies 55 | python3 -m pip install -U pip && \ 56 | python3 -m pip install -U setuptools && \ 57 | python3 -m pip install cmake>=3.20.0 wheel && \ 58 | python3 -m pip install -U west==0.12.0 && \ 59 | python3 -m pip install -U nrfutil && \ 60 | python3 -m pip install pc_ble_driver_py && \ 61 | # Newer PIP will not overwrite distutils, so upgrade PyYAML manually 62 | python3 -m pip install --ignore-installed -U PyYAML && \ 63 | # ClangFormat 64 | python3 -m pip install -U six && \ 65 | apt-get -y install clang-format-9 && \ 66 | ln -s /usr/bin/clang-format-9 /usr/bin/clang-format && \ 67 | wget -qO- https://raw.githubusercontent.com/nrfconnect/sdk-nrf/main/.clang-format > /workdir/.clang-format 68 | 69 | # Download sdk-nrf and west dependencies to install pip requirements 70 | FROM base 71 | ARG sdk_nrf_revision=main 72 | RUN \ 73 | mkdir tmp && cd tmp && \ 74 | west init -m https://github.com/nrfconnect/sdk-nrf --mr ${sdk_nrf_revision} && \ 75 | west update --narrow -o=--depth=1 && \ 76 | python3 -m pip install -r zephyr/scripts/requirements.txt && \ 77 | python3 -m pip install -r nrf/scripts/requirements.txt && \ 78 | python3 -m pip install -r bootloader/mcuboot/scripts/requirements.txt && \ 79 | cd .. && rm -rf tmp 80 | 81 | WORKDIR /workdir/project 82 | ENV LC_ALL=C.UTF-8 83 | ENV LANG=C.UTF-8 84 | ENV XDG_CACHE_HOME=/workdir/.cache 85 | ENV ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb 86 | ENV GNUARMEMB_TOOLCHAIN_PATH=/workdir/gcc-arm-none-eabi-9-2019-q4-major 87 | ENV ZEPHYR_BASE=/workdir/project/zephyr 88 | ENV PATH="${GNUARMEMB_TOOLCHAIN_PATH}/bin:${PATH}" 89 | ENV PATH="${ZEPHYR_BASE}/scripts:${PATH}" 90 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020-2022, Nordic Semiconductor ASA | nordicsemi.no 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Building nRF Connect SDK applications with Docker 2 | 3 | > 🚨 🚨 🚨 🚨 🚨 Moved to https://github.com/NordicPlayground/nrf-docker 🚨 🚨 🚨 🚨 🚨 4 | 5 | ![Publish Docker](https://github.com/coderbyheart/fw-nrfconnect-nrf-docker/workflows/Publish%20Docker/badge.svg?branch=saga) 6 | (_the [Docker image](https://hub.docker.com/r/coderbyheart/fw-nrfconnect-nrf-docker) is build against [nRF Connect SDK](https://github.com/nrfconnect/sdk-nrf) `main`,`v1.9-branch`,`v1.8-branch`, `v1.7-branch`, `v1.6-branch`, `v1.5-branch`, and `v1.4-branch` every night._) 7 | 8 | This project defines a Docker image that contains all dependencies to run `west` commands with the nRF Connect SDK. Bind mount the project folder you'd like to build, and the output will end up in the same folder (nested in build/zephyr subdir of the app). 9 | 10 | > ℹ️ Read more about this aproach [here](https://devzone.nordicsemi.com/nordic/nrf-connect-sdk-guides/b/getting-started/posts/build-ncs-application-firmware-images-using-docker). 11 | 12 | > ⚠️ The `latest` Docker image tag has been deleted. Use `coderbyheart/fw-nrfconnect-nrf-docker:main`. 13 | 14 | ![Docker + Zephyr -> merged.hex](./diagram.png) 15 | 16 | Install `docker` on your operating system. On Windows you might want to use the [WSL subsystem](https://docs.docker.com/docker-for-wi/workdir/project/ndows/wsl-tech-preview/). 17 | 18 | ## Setup 19 | 20 | You can either build the image from this repository or use a pre-built one from Dockerhub. 21 | 22 | ### Build image locally 23 | 24 | Clone the repo: 25 | 26 | git clone https://github.com/coderbyheart/fw-nrfconnect-nrf-docker 27 | 28 | Build the image (this is only needed once): 29 | 30 | cd fw-nrfconnect-nrf-docker 31 | docker build -t fw-nrfconnect-nrf-docker --build-arg sdk_nrf_revision=v1.9-branch . 32 | 33 | > 🍏 _Note:_ To build for a Mac with the M1 architecture, you need to specify the `arm64` architecture when building: `--build-arg arch=arm64`. 34 | 35 | > ℹ️ The `sdk_nrf_revision` build argument can be used to specify what version of the nRF Connect SDK that will be used when looking up dependencies with pip for the SDK and it's west dependency repositories. The value can be a git _tag_, _branch_ or _sha_ from the [nRF Connect SDK repository](https://github.com/nrfconnect/sdk-nrf). 36 | 37 | ### Use pre-built image from Dockerhub 38 | 39 | > ℹ️ This is a convenient way to quickly build your firmware but using images from untrusted third-parties poses the risk of exposing your source code. 40 | 41 | > 🍏 _Note:_ The prebuilt images are not available for `arm64` architecture (Apple M1), because GitHub Actions don't have hosted runners with Apple M1 yet. 42 | 43 | To use the pre-built image [`coderbyheart/fw-nrfconnect-nrf-docker:main`](https://hub.docker.com/r/coderbyheart/fw-nrfconnect-nrf-docker); add `coderbyheart/` before the image name and `:tag` after. Replace `tag` with one of the [available tags](https://hub.docker.com/r/coderbyheart/fw-nrfconnect-nrf-docker/tags) on the Dockerhub image. The only difference between the tags are which Python dependencies are pre-installed in the image based on the different `requirements.txt` files from the nRF Connect SDK repository's west dependencies. 44 | 45 | docker run --rm -v ${PWD}:/workdir/project coderbyheart/fw-nrfconnect-nrf-docker:main ... 46 | 47 | The rest of the documentation will use the local name `fw-nrfconnect-nrf-docker`, but any of them can use `coderbyheart/fw-nrfconnect-nrf-docker:main` (or a different tag) instead. 48 | 49 | ### Initialize and update west dependencies 50 | 51 | Setting up the nRF Connect SDK to build sample applications and a stand-alone repository is a bit different, so we'll demonstrate both. 52 | 53 | #### Using the nRF Connect SDK 54 | 55 | mkdir nrfconnect && cd nrfconnect 56 | docker run --rm -v ${PWD}:/workdir/project fw-nrfconnect-nrf-docker /bin/bash -c '\ 57 | west init -m https://github.com/nrfconnect/sdk-nrf && \ 58 | west update --narrow -o=--depth=1' 59 | 60 | #### Using it with an out-of-tree repository 61 | 62 | Because west installs the dependency repository in the parent-folder of the project folder we need to have an extra subfolder where the custom firmware code is located. Then the containing folder can be mounted when running the container and the output from west will be stored alongside the custom firmware folder. Here's an example folder layout for the `my-application`: 63 | 64 | build-with-nrf-connect-sdk 65 | ├── bootloader 66 | ├── mbedtls 67 | ├── modules 68 | ├── my-application 69 | ├── nrf 70 | ├── nrfxlib 71 | ├── test 72 | ├── tools 73 | └── zephyr 74 | 75 | Now we can initialize the image for use with our out-of-tree firmware folder: 76 | 77 | mkdir build-with-nrf-connect-sdk && cd build-with-nrf-connect-sdk 78 | git clone https://github.com/my-org/my-application 79 | docker run --rm -v ${PWD}:/workdir/project fw-nrfconnect-nrf-docker /bin/bash -c '\ 80 | cd my-application && \ 81 | west init -l && \ 82 | west update --narrow -o=--depth=1' 83 | 84 | ### Build the firmware 85 | 86 | To demonstrate, we'll build the _asset_tracker_v2_ application from sdk-nrf: 87 | 88 | docker run --rm -v ${PWD}:/workdir/project \ 89 | -w /workdir/project/nrf/applications/asset_tracker_v2 \ 90 | fw-nrfconnect-nrf-docker \ 91 | west build -p always -b nrf9160dk_nrf9160_ns 92 | 93 | The firmware file will be located here: `nrf/applications/asset_tracker_v2/build/zephyr/merged.hex`. Because it's inside the folder that is bind mounted when running the image, it is also available outside of the Docker image. 94 | 95 | > ℹ️ The `-p always` build argument is to do a pristine build. It is similar to cleaning the build folder and is used because it is less error-prone to a previous build with different configuration. To speed up subsequent build with the same configuration you can remove this argument to avoid re-building code that haven't been modified since the previous build. 96 | 97 | To build a stand-alone project, replace `-w /workdir/project/nrf/applications/asset_tracker_v2` with the name of the applications folder inside the docker container: 98 | 99 | # run from the build-with-nrf-connect-sdk 100 | docker run --rm -v ${PWD}:/workdir/project \ 101 | -w /workdir/project/my-application \ 102 | fw-nrfconnect-nrf-docker \ 103 | west build -p always -b nrf9160dk_nrf9160_ns 104 | 105 | ## Full example 106 | 107 | # build docker image 108 | git clone https://github.com/coderbyheart/fw-nrfconnect-nrf-docker 109 | cd fw-nrfconnect-nrf-docker 110 | docker build -t fw-nrfconnect-nrf-docker --build-arg sdk_nrf_revision=v1.9-branch . 111 | cd .. 112 | 113 | # initialize sdk-nrf and build asset_tracker_v2 application 114 | mkdir nrfconnect && cd nrfconnect 115 | docker run --rm -v ${PWD}:/workdir/project fw-nrfconnect-nrf-docker /bin/bash -c '\ 116 | west init -m https://github.com/nrfconnect/sdk-nrf --mr v1.9-branch && \ 117 | west update --narrow -o=--depth=1 && \ 118 | cd nrf/applications/asset_tracker_v2 && \ 119 | west build -p always -b nrf9160dk_nrf9160_ns' 120 | ls -la nrf/applications/asset_tracker_v2/build/zephyr/merged.hex 121 | 122 | > ℹ️ The `--mr` argument to `west init` specifies the manifest revision, which is the same as the SDK version. It can be a _branch_, _tag_ or a _sha_. It's recommended to select a recent stable version. Which will be tagged. See available [tags in the sdk-nrf repo](https://github.com/nrfconnect/sdk-nrf/tags). 123 | 124 | ### Build a Zephyr sample using the hosted image 125 | 126 | This builds the `hci_uart` sample and stores the `hci_uart.hex` file in the current directory: 127 | 128 | # assumes `west init` and `west update` from before 129 | docker run --rm -v ${PWD}:/workdir/project coderbyheart/fw-nrfconnect-nrf-docker:main \ 130 | west build zephyr/samples/bluetooth/hci_uart -p always -b nrf9160dk_nrf52840 131 | ls -la build/zephyr && cp build/zephyr/zephyr.hex ./hci_uart.hex 132 | 133 | ## Flashing 134 | 135 | > ℹ️ Docker for Mac OS and Windows does not have support for USB yet, so this will only work on Linux computers. 136 | 137 | # assumes asset_tracker_v2 built already (see above) 138 | docker run --rm -v ${PWD}:/workdir/project \ 139 | -w /workdir/project/nrf/applications/asset_tracker_v2 \ 140 | fw-nrfconnect-nrf-docker \ 141 | --device=/dev/ttyACM0 --privileged \ 142 | fw-nrfconnect-nrf-docker \ 143 | west flash 144 | 145 | ## ClangFormat 146 | 147 | The image comes with [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) and the [nRF Connect SDK formatting rules](https://github.com/nrfconnect/sdk-nrf/blob/main/.clang-format) so you can run for example 148 | 149 | docker run --name fw-nrfconnect-nrf-docker -d coderbyheart/fw-nrfconnect-nrf-docker tail -f /dev/null 150 | find ./src -type f -iname \*.h -o -iname \*.c \ 151 | | xargs -I@ /bin/bash -c "\ 152 | tmpfile=\$(mktemp /tmp/clang-formatted.XXXXXX) && \ 153 | docker exec -i fw-nrfconnect-nrf-docker clang-format < @ > \$tmpfile && \ 154 | cmp --silent @ \$tmpfile || (mv \$tmpfile @ && echo @ formatted.)" 155 | docker kill fw-nrfconnect-nrf-docker 156 | docker rm fw-nrfconnect-nrf-docker 157 | 158 | to format your sources. 159 | 160 | > ℹ️ Instead of having `clang-format` overwrite the source code file itself, the above command passes the source code file on stdin to clang-format and then overwrites it outside of the container. Otherwise the overwritten file will be owner by the root user (because the Docker daemon is run as root). 161 | 162 | ## Interactive usage 163 | 164 | # from a folder you've initialized with west already 165 | docker run -it --name fw-nrfconnect-nrf-docker -v ${PWD}:/workdir/project \ 166 | fw-nrfconnect-nrf-docker /bin/bash 167 | 168 | > ℹ️ On Linux add `--device=/dev/ttyACM0 --privileged` to be able to flash from the Docker container. 169 | 170 | Then, inside the container: 171 | 172 | cd nrf/applications/asset_tracker_v2 173 | west build -p always -b nrf9160dk_nrf9160_ns 174 | west flash # only works on linux - use nrf desktop tools on Windows/Mac OS 175 | west build 176 | ... 177 | 178 | Meanwhile, inside or outside of the container, you may modify the code and repeat the build/flash cycle. 179 | 180 | Later after closing the container you may re-open it by name to continue where you left off: 181 | 182 | docker start -i fw-nrfconnect-nrf-docker 183 | -------------------------------------------------------------------------------- /diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderbyheart/fw-nrfconnect-nrf-docker/845498eacb98810c27fc700499f07fc4ecc63144/diagram.png --------------------------------------------------------------------------------