-
Notifications
You must be signed in to change notification settings - Fork 35
/
Dockerfile
92 lines (83 loc) · 3.24 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
FROM ubuntu:22.04 as base
WORKDIR /workdir
ARG sdk_nrf_branch=v2.7-branch
ARG toolchain_version=v2.7.0
ARG sdk_nrf_commit
ARG NORDIC_COMMAND_LINE_TOOLS_VERSION="10-24-0/nrf-command-line-tools-10.24.0"
ARG arch=amd64
ENV DEBIAN_FRONTEND=noninteractive
SHELL [ "/bin/bash", "-euxo", "pipefail", "-c" ]
# gcc-multilib make = Host tools for native_sim build
# python 3.8 is installed by toolchain manager hence older version of libffi is required
RUN <<EOT
apt-get -y update
apt-get -y upgrade
apt-get -y install wget unzip clang-format gcc-multilib make libffi7
apt-get -y clean
rm -rf /var/lib/apt/lists/*
EOT
# Install toolchain
# Make nrfutil install in a shared location, because when used with GitHub
# Actions, the image will be launched with the home dir mounted from the local
# checkout.
ENV NRFUTIL_HOME=/usr/local/share/nrfutil
RUN <<EOT
wget -q https://developer.nordicsemi.com/.pc-tools/nrfutil/x64-linux/nrfutil
mv nrfutil /usr/local/bin
chmod +x /usr/local/bin/nrfutil
nrfutil install toolchain-manager
nrfutil install toolchain-manager search
nrfutil toolchain-manager install --ncs-version ${toolchain_version}
nrfutil toolchain-manager list
rm -f /root/ncs/downloads/*
EOT
#
# ClangFormat
#
RUN <<EOT
wget -qO- https://raw.githubusercontent.com/nrfconnect/sdk-nrf/${sdk_nrf_branch}/.clang-format > /workdir/.clang-format
EOT
# Nordic command line tools
# Releases: https://www.nordicsemi.com/Products/Development-tools/nrf-command-line-tools/download
RUN <<EOT
NCLT_BASE=https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/desktop-software/nrf-command-line-tools/sw/versions-10-x-x
echo "Host architecture: $arch"
case $arch in
"amd64")
NCLT_URL="${NCLT_BASE}/${NORDIC_COMMAND_LINE_TOOLS_VERSION}_linux-amd64.tar.gz"
;;
"arm64")
NCLT_URL="${NCLT_BASE}/${NORDIC_COMMAND_LINE_TOOLS_VERSION}_linux-arm64.tar.gz"
;;
esac
echo "NCLT_URL=${NCLT_URL}"
if [ ! -z "$NCLT_URL" ]; then
mkdir tmp && cd tmp
wget -qO - "${NCLT_URL}" | tar --no-same-owner -xz
# Install included JLink
mkdir /opt/SEGGER
tar xzf JLink_*.tgz -C /opt/SEGGER
mv /opt/SEGGER/JLink* /opt/SEGGER/JLink
# Install nrf-command-line-tools
cp -r ./nrf-command-line-tools /opt
ln -s /opt/nrf-command-line-tools/bin/nrfjprog /usr/local/bin/nrfjprog
ln -s /opt/nrf-command-line-tools/bin/mergehex /usr/local/bin/mergehex
cd .. && rm -rf tmp ;
else
echo "Skipping nRF Command Line Tools (not available for $arch)" ;
fi
EOT
# Prepare image with a ready to use build environment
SHELL ["nrfutil","toolchain-manager","launch","/bin/bash","--","-c"]
RUN <<EOT
west init -m https://github.com/nrfconnect/sdk-nrf --mr ${sdk_nrf_branch} .
if [[ $sdk_nrf_commit =~ "^[a-fA-F0-9]{32}$" ]]; then
git checkout ${sdk_nrf_commit};
fi
west update --narrow -o=--depth=1
EOT
# Launch into build environment with the passed arguments
# Currently this is not supported in GitHub Actions
# See https://github.com/actions/runner/issues/1964
ENTRYPOINT [ "nrfutil", "toolchain-manager", "launch", "/bin/bash", "--", "/root/entry.sh" ]
COPY ./entry.sh /root/entry.sh