Skip to content

Commit a18da7a

Browse files
committed
ci: Use heredoc for multi-line RUN
As of Docker version 23.0, BuildKit is the default builder and the heredoc syntax is therefore supported. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
1 parent f102d48 commit a18da7a

File tree

1 file changed

+134
-102
lines changed

1 file changed

+134
-102
lines changed

‎Dockerfile.ci‎

Lines changed: 134 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -38,55 +38,65 @@ ARG WGET_ARGS="-q --show-progress --progress=bar:force:noscroll"
3838

3939
# Install Kitware ninja
4040
# NOTE: Pre-built Kitware ninja binaries are only available for x86_64 host.
41-
RUN if [ "${HOSTTYPE}" = "x86_64" ]; then \
42-
wget ${WGET_ARGS} https://github.com/Kitware/ninja/releases/download/v${KITWARE_NINJA_VERSION}/ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu.tar.gz && \
43-
tar xf ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu.tar.gz -C /opt && \
44-
ln -s /opt/ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu/ninja /usr/local/bin && \
45-
rm ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu.tar.gz \
46-
; fi
41+
RUN <<EOF
42+
if [ "${HOSTTYPE}" = "x86_64" ]; then
43+
wget ${WGET_ARGS} https://github.com/Kitware/ninja/releases/download/v${KITWARE_NINJA_VERSION}/ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu.tar.gz
44+
tar xf ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu.tar.gz -C /opt
45+
ln -s /opt/ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu/ninja /usr/local/bin
46+
rm ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu.tar.gz
47+
fi
48+
EOF
4749

4850
# Install ccache
4951
# NOTE: Pre-built ccache binaries are only available for x86_64 host.
50-
RUN if [ "${HOSTTYPE}" = "x86_64" ]; then \
51-
wget ${WGET_ARGS} https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz && \
52-
tar xf ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz -C /opt && \
53-
ln -s /opt/ccache-${CCACHE_VERSION}-linux-x86_64/ccache /usr/local/bin && \
54-
rm ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz \
55-
; fi
52+
RUN <<EOF
53+
if [ "${HOSTTYPE}" = "x86_64" ]; then
54+
wget ${WGET_ARGS} https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz
55+
tar xf ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz -C /opt
56+
ln -s /opt/ccache-${CCACHE_VERSION}-linux-x86_64/ccache /usr/local/bin
57+
rm ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz
58+
fi
59+
EOF
5660

5761
# Install Doxygen (x86 only)
5862
# NOTE: Pre-built Doxygen binaries are only available for x86_64 host.
59-
RUN if [ "${HOSTTYPE}" = "x86_64" ]; then \
60-
wget ${WGET_ARGS} "https://github.com/doxygen/doxygen/releases/download/Release_${DOXYGEN_VERSION//./_}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz" && \
61-
tar xf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz -C /opt && \
62-
ln -s /opt/doxygen-${DOXYGEN_VERSION}/bin/doxygen /usr/local/bin && \
63-
rm doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz \
64-
; fi
63+
RUN <<EOF
64+
if [ "${HOSTTYPE}" = "x86_64" ]; then
65+
wget ${WGET_ARGS} "https://github.com/doxygen/doxygen/releases/download/Release_${DOXYGEN_VERSION//./_}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz"
66+
tar xf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz -C /opt
67+
ln -s /opt/doxygen-${DOXYGEN_VERSION}/bin/doxygen /usr/local/bin
68+
rm doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz
69+
fi
70+
EOF
6571

6672

6773
# Install renode (x86 only)
6874
# NOTE: Renode is currently only available for x86_64 host.
69-
RUN if [ "${HOSTTYPE}" = "x86_64" ]; then \
70-
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \
71-
echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | tee /etc/apt/sources.list.d/mono-official-stable.list && \
72-
apt-get -y update && \
73-
wget ${WGET_ARGS} https://github.com/renode/renode/releases/download/v${RENODE_VERSION}/renode_${RENODE_VERSION}_amd64.deb && \
74-
apt-get install -y ./renode_${RENODE_VERSION}_amd64.deb && \
75-
rm renode_${RENODE_VERSION}_amd64.deb && \
76-
pip3 install -r /opt/renode/tests/requirements.txt --no-cache-dir \
77-
; fi
75+
RUN <<EOF
76+
if [ "${HOSTTYPE}" = "x86_64" ]; then
77+
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
78+
echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | tee /etc/apt/sources.list.d/mono-official-stable.list
79+
apt-get -y update
80+
wget ${WGET_ARGS} https://github.com/renode/renode/releases/download/v${RENODE_VERSION}/renode_${RENODE_VERSION}_amd64.deb
81+
apt-get install -y ./renode_${RENODE_VERSION}_amd64.deb
82+
rm renode_${RENODE_VERSION}_amd64.deb
83+
pip3 install -r /opt/renode/tests/requirements.txt --no-cache-dir
84+
fi
85+
EOF
7886

7987
# Install BSIM
8088
# Note: west needs an extra folder level, so we create a link to the old location to be backwards compatible
81-
RUN mkdir -p /opt/bsim_west && \
82-
cd /opt/ && \
83-
west init -m https://github.com/zephyrproject-rtos/babblesim-manifest.git --mr ${BSIM_VERSION} bsim_west && \
84-
cd bsim_west/bsim && \
85-
west update && \
86-
make everything -j 8 && \
87-
echo ${BSIM_VERSION} > ./version && \
88-
chmod ag+w . -R && \
89+
RUN <<EOF
90+
mkdir -p /opt/bsim_west
91+
cd /opt/
92+
west init -m https://github.com/zephyrproject-rtos/babblesim-manifest.git --mr ${BSIM_VERSION} bsim_west
93+
cd bsim_west/bsim
94+
west update
95+
make everything -j 8
96+
echo ${BSIM_VERSION} > ./version
97+
chmod ag+w . -R
8998
ln -s /opt/bsim_west/bsim /opt/bsim
99+
EOF
90100

91101
# Install cargo environment
92102
RUN wget -q -O- "https://sh.rustup.rs" | sh -s -- -y --default-toolchain 1.86
@@ -96,101 +106,123 @@ RUN ~/.cargo/bin/cargo install uefi-run --root /usr
96106

97107
# Install target support for Rust. This is the list as of the current
98108
# time.
99-
RUN \
100-
~/.cargo/bin/rustup target install riscv32i-unknown-none-elf && \
101-
~/.cargo/bin/rustup target install riscv64imac-unknown-none-elf && \
102-
~/.cargo/bin/rustup target install thumbv6m-none-eabi && \
103-
~/.cargo/bin/rustup target install thumbv7em-none-eabi && \
104-
~/.cargo/bin/rustup target install thumbv7m-none-eabi && \
105-
~/.cargo/bin/rustup target install thumbv8m.main-none-eabi && \
109+
RUN <<EOF
110+
~/.cargo/bin/rustup target install riscv32i-unknown-none-elf
111+
~/.cargo/bin/rustup target install riscv64imac-unknown-none-elf
112+
~/.cargo/bin/rustup target install thumbv6m-none-eabi
113+
~/.cargo/bin/rustup target install thumbv7em-none-eabi
114+
~/.cargo/bin/rustup target install thumbv7m-none-eabi
115+
~/.cargo/bin/rustup target install thumbv8m.main-none-eabi
106116
~/.cargo/bin/rustup target install x86_64-unknown-none
117+
EOF
107118

108119
# Install LLVM and Clang
109-
RUN wget ${WGET_ARGS} https://apt.llvm.org/llvm.sh && \
110-
chmod +x llvm.sh && \
111-
./llvm.sh ${LLVM_VERSION} all && \
120+
RUN <<EOF
121+
wget ${WGET_ARGS} https://apt.llvm.org/llvm.sh
122+
chmod +x llvm.sh
123+
./llvm.sh ${LLVM_VERSION} all
112124
rm -f llvm.sh
125+
EOF
113126

114127
# Install sparse package for static analysis
115-
RUN mkdir -p /opt/sparse && \
116-
cd /opt/sparse && \
117-
git clone https://git.kernel.org/pub/scm/devel/sparse/sparse.git && \
118-
cd sparse && git checkout ${SPARSE_VERSION} && \
119-
make -j8 && \
120-
PREFIX=/opt/sparse make install && \
128+
RUN <<EOF
129+
mkdir -p /opt/sparse
130+
cd /opt/sparse
131+
git clone https://git.kernel.org/pub/scm/devel/sparse/sparse.git
132+
cd sparse
133+
git checkout ${SPARSE_VERSION}
134+
make -j8
135+
PREFIX=/opt/sparse make install
121136
rm -rf /opt/sparse/sparse
137+
EOF
122138

123139
# Install protobuf-compiler
124-
RUN mkdir -p /opt/protoc && \
125-
cd /opt/protoc && \
126-
PROTOC_HOSTTYPE=$(case $HOSTTYPE in x86_64) echo "x86_64";; aarch64) echo "aarch_64";; esac) && \
127-
wget ${WGET_ARGS} https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${PROTOC_HOSTTYPE}.zip && \
128-
unzip protoc-${PROTOC_VERSION}-linux-${PROTOC_HOSTTYPE}.zip && \
129-
ln -s /opt/protoc/bin/protoc /usr/local/bin && \
140+
RUN <<EOF
141+
mkdir -p /opt/protoc
142+
cd /opt/protoc
143+
PROTOC_HOSTTYPE=$(case $HOSTTYPE in x86_64) echo "x86_64";; aarch64) echo "aarch_64";; esac)
144+
wget ${WGET_ARGS} https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${PROTOC_HOSTTYPE}.zip
145+
unzip protoc-${PROTOC_VERSION}-linux-${PROTOC_HOSTTYPE}.zip
146+
ln -s /opt/protoc/bin/protoc /usr/local/bin
130147
rm -f protoc-${PROTOC_VERSION}-linux-${PROTOC_HOSTTYPE}.zip
148+
EOF
131149

132150
# Install FVP
133151
#
134152
# Ecosystem FVP License permits redistribution (refer to the relevant license available in the container).
135-
RUN set -o pipefail && \
136-
apt update && \
137-
apt install software-properties-common && \
138-
add-apt-repository -y ppa:deadsnakes/ppa && \
139-
apt install -y python3.9-dev && \
140-
mkdir -p /opt/fvps && \
141-
cd /opt/fvps && \
142-
if [ "${HOSTTYPE}" = "x86_64" ]; then SUFFIX=""; else SUFFIX="_armv8l"; fi && \
143-
\
144-
declare -A FVP_INSTALLABLE=( \
145-
["300"]="${FVP_CORSTONE300_VERSION}" \
146-
["310"]="${FVP_CORSTONE310_VERSION}" \
147-
["315"]="${FVP_CORSTONE315_VERSION}" \
148-
["320"]="${FVP_CORSTONE320_VERSION}" \
149-
) ; \
150-
for corstone in ${!FVP_INSTALLABLE[@]} ; \
151-
do version_build="${FVP_INSTALLABLE[$corstone]}" \
152-
&& echo "Downloading Corstone-${corstone} ${version_build}" \
153-
&& wget ${WGET_ARGS} -O- https://developer.arm.com/-/cdn-downloads/permalink/FVPs-Corstone-IoT/Corstone-${corstone}/FVP_Corstone_SSE-${corstone}_${version_build}_Linux64${SUFFIX}.tgz | tar xz \
154-
&& ./FVP_Corstone_SSE-${corstone}.sh --no-interactive --i-agree-to-the-contained-eula -d /opt/fvps/Corstone-${corstone} \
155-
&& rm FVP_Corstone_SSE-${corstone}.sh \
156-
&& ln -s /opt/fvps/Corstone-${corstone}/models/*/FVP_* /usr/local/bin ; \
157-
done && \
158-
\
159-
declare -A FVP_EXTRACTABLE=( \
160-
["RevC-2xAEMvA"]="${FVP_BASE_REVC_VERSION}" \
161-
["AEMv8R"]="${FVP_BASE_AEMV8R_VERSION}" \
162-
) && \
163-
for base in ${!FVP_EXTRACTABLE[@]} ; \
164-
do version_build="${FVP_EXTRACTABLE[$base]}" \
165-
&& echo "Downloading Base-${base} ${FVP_EXTRACTABLE[$base]}" \
166-
&& IFS="_" read version build <<< "${version_build}" \
167-
&& wget ${WGET_ARGS} -O- https://developer.arm.com/-/cdn-downloads/permalink/FVPs-Architecture/FM-${version}/FVP_Base_${base}_${version_build}_Linux64${SUFFIX}.tgz | tar xz \
168-
; done && \
153+
RUN <<EOF
154+
set -o pipefail
155+
apt update
156+
apt install software-properties-common
157+
add-apt-repository -y ppa:deadsnakes/ppa
158+
apt install -y python3.9-dev
159+
160+
mkdir -p /opt/fvps
161+
cd /opt/fvps
162+
163+
if [ "${HOSTTYPE}" = "x86_64" ]; then
164+
SUFFIX=""
165+
else
166+
SUFFIX="_armv8l"
167+
fi
168+
169+
declare -A FVP_INSTALLABLE=(
170+
["300"]="${FVP_CORSTONE300_VERSION}"
171+
["310"]="${FVP_CORSTONE310_VERSION}"
172+
["315"]="${FVP_CORSTONE315_VERSION}"
173+
["320"]="${FVP_CORSTONE320_VERSION}"
174+
)
175+
for corstone in ${!FVP_INSTALLABLE[@]}; do
176+
version_build="${FVP_INSTALLABLE[$corstone]}"
177+
echo "Downloading Corstone-${corstone} ${version_build}"
178+
wget ${WGET_ARGS} -O- https://developer.arm.com/-/cdn-downloads/permalink/FVPs-Corstone-IoT/Corstone-${corstone}/FVP_Corstone_SSE-${corstone}_${version_build}_Linux64${SUFFIX}.tgz | tar xz
179+
./FVP_Corstone_SSE-${corstone}.sh --no-interactive --i-agree-to-the-contained-eula -d /opt/fvps/Corstone-${corstone}
180+
rm FVP_Corstone_SSE-${corstone}.sh
181+
ln -s /opt/fvps/Corstone-${corstone}/models/*/FVP_* /usr/local/bin
182+
done
183+
184+
declare -A FVP_EXTRACTABLE=(
185+
["RevC-2xAEMvA"]="${FVP_BASE_REVC_VERSION}"
186+
["AEMv8R"]="${FVP_BASE_AEMV8R_VERSION}"
187+
)
188+
for base in ${!FVP_EXTRACTABLE[@]}; do
189+
version_build="${FVP_EXTRACTABLE[$base]}"
190+
echo "Downloading Base-${base} ${FVP_EXTRACTABLE[$base]}"
191+
IFS="_" read version build <<< "${version_build}"
192+
wget ${WGET_ARGS} -O- https://developer.arm.com/-/cdn-downloads/permalink/FVPs-Architecture/FM-${version}/FVP_Base_${base}_${version_build}_Linux64${SUFFIX}.tgz | tar xz
193+
done
194+
169195
ln -s /opt/fvps/*_pkg/models/*/FVP_* /usr/local/bin
196+
EOF
170197

171198
# Install Zephyr SDK
172-
RUN mkdir -p /opt/toolchains && \
173-
cd /opt/toolchains && \
174-
wget ${WGET_ARGS} https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZSDK_VERSION}/zephyr-sdk-${ZSDK_VERSION}_linux-${HOSTTYPE}.tar.xz && \
175-
tar xf zephyr-sdk-${ZSDK_VERSION}_linux-${HOSTTYPE}.tar.xz && \
176-
zephyr-sdk-${ZSDK_VERSION}/setup.sh -t all -h -c && \
199+
RUN <<EOF
200+
mkdir -p /opt/toolchains
201+
cd /opt/toolchains
202+
wget ${WGET_ARGS} https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZSDK_VERSION}/zephyr-sdk-${ZSDK_VERSION}_linux-${HOSTTYPE}.tar.xz
203+
tar xf zephyr-sdk-${ZSDK_VERSION}_linux-${HOSTTYPE}.tar.xz
204+
zephyr-sdk-${ZSDK_VERSION}/setup.sh -t all -h -c
177205
rm zephyr-sdk-${ZSDK_VERSION}_linux-${HOSTTYPE}.tar.xz
178-
206+
EOF
179207

180208
# Clean up stale packages
181-
RUN apt-get clean -y && \
182-
apt-get autoremove --purge -y && \
209+
RUN <<EOF
210+
apt-get clean -y
211+
apt-get autoremove --purge -y
183212
rm -rf /var/lib/apt/lists/*
213+
EOF
184214

185215
# Run the Zephyr SDK setup script as 'user' in order to ensure that the
186216
# `Zephyr-sdk` CMake package is located in the package registry under the
187217
# user's home directory.
188218
USER $USERNAME
189219

190-
RUN sudo -E -- bash -c ' \
191-
/opt/toolchains/zephyr-sdk-${ZSDK_VERSION}/setup.sh -c && \
192-
chown -R $USERNAME:$USERNAME /home/$USERNAME/.cmake \
220+
RUN <<EOF
221+
sudo -E -- bash -c '
222+
/opt/toolchains/zephyr-sdk-${ZSDK_VERSION}/setup.sh -c &&
223+
chown -R $USERNAME:$USERNAME /home/$USERNAME/.cmake
193224
'
225+
EOF
194226

195227
USER root
196228

0 commit comments

Comments
 (0)