Skip to content

Commit 13fef09

Browse files
committed
base: 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 941ba57 commit 13fef09

File tree

1 file changed

+43
-23
lines changed

1 file changed

+43
-23
lines changed

Dockerfile.base

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ SHELL ["/bin/bash", "-c"]
2020
ENV DEBIAN_FRONTEND=noninteractive
2121

2222
# Set up Ubuntu mirrors
23-
RUN sed -i "s#archive.ubuntu.com/ubuntu#${UBUNTU_MIRROR_ARCHIVE}#" /etc/apt/sources.list.d/ubuntu.sources && \
24-
sed -i "s#security.ubuntu.com/ubuntu#${UBUNTU_MIRROR_SECURITY}#" /etc/apt/sources.list.d/ubuntu.sources && \
23+
RUN <<EOF
24+
sed -i "s#archive.ubuntu.com/ubuntu#${UBUNTU_MIRROR_ARCHIVE}#" /etc/apt/sources.list.d/ubuntu.sources
25+
sed -i "s#security.ubuntu.com/ubuntu#${UBUNTU_MIRROR_SECURITY}#" /etc/apt/sources.list.d/ubuntu.sources
2526
sed -i "s#ports.ubuntu.com/ubuntu-ports#${UBUNTU_MIRROR_PORTS}#" /etc/apt/sources.list.d/ubuntu.sources
27+
EOF
2628

2729
# Install base packages
28-
RUN apt-get -y update && \
29-
apt-get -y upgrade && \
30+
RUN <<EOF
31+
apt-get -y update
32+
apt-get -y upgrade
3033
apt-get install --no-install-recommends -y \
3134
software-properties-common \
3235
lsb-release \
@@ -94,36 +97,48 @@ RUN apt-get -y update && \
9497
ovmf \
9598
xz-utils \
9699
thrift-compiler
100+
EOF
97101

98102
# Install multi-lib gcc (x86 only)
99-
RUN if [ "${HOSTTYPE}" = "x86_64" ]; then \
100-
apt-get install --no-install-recommends -y \
101-
gcc-multilib \
102-
g++-multilib \
103+
RUN <<EOF
104+
if [ "${HOSTTYPE}" = "x86_64" ]; then
105+
apt-get install --no-install-recommends -y \
106+
gcc-multilib \
107+
g++-multilib
103108
; fi
109+
EOF
104110

105111
# Install i386 packages (x86 only)
106-
RUN if [ "${HOSTTYPE}" = "x86_64" ]; then \
107-
dpkg --add-architecture i386 && \
108-
apt-get -y update && \
109-
apt-get -y upgrade && \
110-
apt-get install --no-install-recommends -y \
111-
libsdl2-dev:i386 libfuse-dev:i386 libc6-dbg:i386 python3\
112+
RUN <<EOF
113+
if [ "${HOSTTYPE}" = "x86_64" ]; then
114+
dpkg --add-architecture i386
115+
apt-get -y update
116+
apt-get -y upgrade
117+
apt-get install --no-install-recommends -y \
118+
libsdl2-dev:i386 \
119+
libfuse-dev:i386 \
120+
libc6-dbg:i386 \
121+
python3
112122
; fi
123+
EOF
113124

114125
# Initialise system locale
115126
RUN locale-gen en_US.UTF-8
116127
ENV LANG=en_US.UTF-8
117128
ENV LANGUAGE=en_US:en
118129
ENV LC_ALL=en_US.UTF-8
119130

120-
RUN mkdir -p ${PYTHON_VENV_PATH} && \
121-
python3 -m venv ${PYTHON_VENV_PATH}
131+
RUN <<EOF
132+
mkdir -p ${PYTHON_VENV_PATH}
133+
python3 -m venv ${PYTHON_VENV_PATH}
134+
EOF
122135

123136
ENV PATH=${PYTHON_VENV_PATH}/bin:$PATH
124137

125-
RUN cd ${PYTHON_VENV_PATH}/bin && \
126-
pip install --no-cache-dir --upgrade pip setuptools wheel
138+
RUN <<EOF
139+
cd ${PYTHON_VENV_PATH}/bin
140+
pip install --no-cache-dir --upgrade pip setuptools wheel
141+
EOF
127142

128143
# Install Python dependencies
129144
RUN pip3 install --no-cache-dir \
@@ -132,21 +147,26 @@ RUN pip3 install --no-cache-dir \
132147
GitPython imgtool junitparser junit2html numpy protobuf grpcio-tools PyGithub \
133148
pylint sh statistics west \
134149
nrf-regtool~=9.0.1
150+
135151
# Run pip check on x86 only for now, it fails on arm.
136152
RUN if [ "${HOSTTYPE}" = "x86_64" ]; then \
137153
pip3 check \
138154
; fi
139155

140156
# Clean up stale packages
141-
RUN apt-get clean -y && \
142-
apt-get autoremove --purge -y && \
157+
RUN <<EOF
158+
apt-get clean -y
159+
apt-get autoremove --purge -y
143160
rm -rf /var/lib/apt/lists/*
161+
EOF
144162

145163
# Create 'user' account
146164
RUN groupadd -g $GID -o $USERNAME
147165

148-
RUN useradd -u $UID -m -g $USERNAME -G plugdev $USERNAME \
149-
&& echo $USERNAME ' ALL = NOPASSWD: ALL' > /etc/sudoers.d/$USERNAME \
150-
&& chmod 0440 /etc/sudoers.d/$USERNAME
166+
RUN <<EOF
167+
useradd -u $UID -m -g $USERNAME -G plugdev $USERNAME
168+
echo $USERNAME ' ALL = NOPASSWD: ALL' > /etc/sudoers.d/$USERNAME
169+
chmod 0440 /etc/sudoers.d/$USERNAME
170+
EOF
151171

152172
USER root

0 commit comments

Comments
 (0)