Skip to content

Commit 837d10a

Browse files
committed
ci: extract minimum environment needed to run functional tests
We don't need multiple (cross) compilers to run tests and GitHub Actions currently hamstrings our ability to thin down the runner using conventional means, so we thin down the container itself.
1 parent 4bcd093 commit 837d10a

File tree

4 files changed

+131
-109
lines changed

4 files changed

+131
-109
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
**
22
!contrib/containers/ci/ci.Dockerfile
3+
!contrib/containers/ci/ci-slim.Dockerfile
34
!contrib/containers/deploy/Dockerfile
45
!contrib/containers/develop/Dockerfile
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Builder for cppcheck
2+
FROM debian:bookworm-slim AS cppcheck-builder
3+
ARG CPPCHECK_VERSION=2.13.0
4+
RUN set -ex; \
5+
apt-get update && apt-get install -y --no-install-recommends \
6+
curl \
7+
ca-certificates \
8+
cmake \
9+
make \
10+
g++ \
11+
&& rm -rf /var/lib/apt/lists/*; \
12+
echo "Downloading Cppcheck version: ${CPPCHECK_VERSION}"; \
13+
curl -fL "https://github.com/danmar/cppcheck/archive/${CPPCHECK_VERSION}.tar.gz" -o /tmp/cppcheck.tar.gz; \
14+
mkdir -p /src/cppcheck && tar -xzf /tmp/cppcheck.tar.gz -C /src/cppcheck --strip-components=1; \
15+
rm /tmp/cppcheck.tar.gz; \
16+
cd /src/cppcheck; \
17+
mkdir build && cd build && cmake .. && cmake --build . -j"$(nproc)"; \
18+
strip bin/cppcheck
19+
20+
# Main image
21+
FROM ubuntu:noble
22+
23+
# Include built assets
24+
COPY --from=cppcheck-builder /src/cppcheck/build/bin/cppcheck /usr/local/bin/cppcheck
25+
COPY --from=cppcheck-builder /src/cppcheck/cfg /usr/local/share/Cppcheck/cfg
26+
ENV PATH="/usr/local/bin:${PATH}"
27+
28+
# Needed to prevent tzdata hanging while expecting user input
29+
ENV DEBIAN_FRONTEND="noninteractive" TZ="Europe/London"
30+
31+
# Build and base stuff
32+
ENV APT_ARGS="-y --no-install-recommends --no-upgrade"
33+
34+
# Packages needed to build Python and extract artifacts
35+
RUN set -ex; \
36+
apt-get update && apt-get install ${APT_ARGS} \
37+
build-essential \
38+
ca-certificates \
39+
curl \
40+
g++ \
41+
git \
42+
libbz2-dev \
43+
libffi-dev \
44+
liblzma-dev \
45+
libncurses5-dev \
46+
libncursesw5-dev \
47+
libreadline-dev \
48+
libsqlite3-dev \
49+
libssl-dev \
50+
make \
51+
tk-dev \
52+
xz-utils \
53+
zlib1g-dev \
54+
zstd \
55+
&& rm -rf /var/lib/apt/lists/*
56+
57+
# Install Python and set it as default
58+
ENV PYENV_ROOT="/usr/local/pyenv"
59+
ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"
60+
# PYTHON_VERSION should match the value in .python-version
61+
ARG PYTHON_VERSION=3.9.18
62+
RUN set -ex; \
63+
curl https://pyenv.run | bash \
64+
&& pyenv update \
65+
&& pyenv install ${PYTHON_VERSION} \
66+
&& pyenv global ${PYTHON_VERSION} \
67+
&& pyenv rehash
68+
69+
# Install Python packages
70+
RUN set -ex; \
71+
pip3 install --no-cache-dir \
72+
codespell==1.17.1 \
73+
flake8==3.8.3 \
74+
jinja2 \
75+
lief==0.13.2 \
76+
multiprocess \
77+
mypy==0.910 \
78+
pyzmq==22.3.0 \
79+
vulture==2.3
80+
81+
# Install packages relied on by tests
82+
ARG DASH_HASH_VERSION=1.4.0
83+
RUN set -ex; \
84+
cd /tmp; \
85+
git clone --depth 1 --no-tags --branch=${DASH_HASH_VERSION} https://github.com/dashpay/dash_hash; \
86+
cd dash_hash && pip3 install -r requirements.txt .; \
87+
cd .. && rm -rf dash_hash
88+
89+
ARG SHELLCHECK_VERSION=v0.7.1
90+
RUN set -ex; \
91+
curl -fL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" -o /tmp/shellcheck.tar.xz; \
92+
mkdir -p /opt/shellcheck && tar -xf /tmp/shellcheck.tar.xz -C /opt/shellcheck --strip-components=1 && rm /tmp/shellcheck.tar.xz
93+
ENV PATH="/opt/shellcheck:${PATH}"
94+
95+
# Packages needed to be able to run sanitizer builds
96+
ARG LLVM_VERSION=18
97+
RUN set -ex; \
98+
. /etc/os-release; \
99+
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key > /etc/apt/trusted.gpg.d/apt.llvm.org.asc; \
100+
echo "deb [signed-by=/etc/apt/trusted.gpg.d/apt.llvm.org.asc] http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-${LLVM_VERSION} main" > /etc/apt/sources.list.d/llvm.list; \
101+
apt-get update && apt-get install ${APT_ARGS} \
102+
"llvm-${LLVM_VERSION}-dev"; \
103+
rm -rf /var/lib/apt/lists/*;
104+
105+
# Setup unprivileged user and configuration files
106+
ARG USER_ID=1000 \
107+
GROUP_ID=1000
108+
RUN set -ex; \
109+
groupmod -g ${GROUP_ID} -n dash ubuntu; \
110+
usermod -u ${USER_ID} -md /home/dash -l dash ubuntu; \
111+
chown ${USER_ID}:${GROUP_ID} -R /home/dash; \
112+
mkdir -p /src/dash && \
113+
chown ${USER_ID}:${GROUP_ID} /src && \
114+
chown ${USER_ID}:${GROUP_ID} -R /src
115+
116+
WORKDIR /src/dash
117+
118+
USER dash

contrib/containers/ci/ci.Dockerfile

Lines changed: 8 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,10 @@
1-
# cppcheck builder
2-
FROM debian:bookworm-slim AS cppcheck-builder
3-
ARG CPPCHECK_VERSION=2.13.0
4-
RUN set -ex; \
5-
apt-get update && apt-get install -y --no-install-recommends \
6-
curl \
7-
ca-certificates \
8-
cmake \
9-
make \
10-
g++ \
11-
&& rm -rf /var/lib/apt/lists/*; \
12-
echo "Downloading Cppcheck version: ${CPPCHECK_VERSION}"; \
13-
curl -fL "https://github.com/danmar/cppcheck/archive/${CPPCHECK_VERSION}.tar.gz" -o /tmp/cppcheck.tar.gz; \
14-
mkdir -p /src/cppcheck && tar -xzf /tmp/cppcheck.tar.gz -C /src/cppcheck --strip-components=1; \
15-
rm /tmp/cppcheck.tar.gz; \
16-
cd /src/cppcheck; \
17-
mkdir build && cd build && cmake .. && cmake --build . -j"$(nproc)"; \
18-
strip bin/cppcheck
19-
20-
# Final Image
21-
FROM ubuntu:noble
22-
COPY --from=cppcheck-builder /src/cppcheck/build/bin/cppcheck /usr/local/bin/cppcheck
23-
COPY --from=cppcheck-builder /src/cppcheck/cfg /usr/local/share/Cppcheck/cfg
1+
# syntax = devthefuture/dockerfile-x
242

25-
# Set Path
26-
ENV PATH="/usr/local/bin:${PATH}"
3+
FROM ./ci-slim.Dockerfile
274

28-
# Needed to prevent tzdata hanging while expecting user input
29-
ENV DEBIAN_FRONTEND="noninteractive" TZ="Europe/London"
30-
31-
# Build and base stuff
32-
# (zlib1g-dev is needed for the Qt host binary builds, but should not be used by target binaries)
33-
ENV APT_ARGS="-y --no-install-recommends --no-upgrade"
5+
# The inherited Dockerfile switches to non-privileged context and we've
6+
# just started configuring this image, give us root access
7+
USER root
348

359
# Install common packages
3610
RUN set -ex; \
@@ -41,28 +15,18 @@ RUN set -ex; \
4115
autoconf \
4216
bear \
4317
bison \
44-
build-essential \
4518
bsdmainutils \
46-
curl \
4719
ccache \
4820
cmake \
49-
g++ \
5021
gettext \
51-
git \
5222
libtool \
5323
unzip \
5424
m4 \
5525
pkg-config \
56-
zlib1g-dev \
5726
&& rm -rf /var/lib/apt/lists/*
5827

59-
# Install Clang+LLVM and set it as default
60-
ARG LLVM_VERSION=18
28+
# Install Clang + LLVM and set it as default
6129
RUN set -ex; \
62-
echo "Installing LLVM and Clang ${LLVM_VERSION}..."; \
63-
. /etc/os-release; \
64-
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key > /etc/apt/trusted.gpg.d/apt.llvm.org.asc; \
65-
echo "deb [signed-by=/etc/apt/trusted.gpg.d/apt.llvm.org.asc] http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-${LLVM_VERSION} main" > /etc/apt/sources.list.d/llvm.list; \
6630
apt-get update && apt-get install ${APT_ARGS} \
6731
"clang-${LLVM_VERSION}" \
6832
"clangd-${LLVM_VERSION}" \
@@ -73,8 +37,7 @@ RUN set -ex; \
7337
"libclang-${LLVM_VERSION}-dev" \
7438
"libclang-rt-${LLVM_VERSION}-dev" \
7539
"lld-${LLVM_VERSION}" \
76-
"lldb-${LLVM_VERSION}" \
77-
"llvm-${LLVM_VERSION}-dev"; \
40+
"lldb-${LLVM_VERSION}"; \
7841
rm -rf /var/lib/apt/lists/*; \
7942
echo "Setting defaults..."; \
8043
lldbUpdAltArgs="update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-${LLVM_VERSION} 100"; \
@@ -88,48 +51,6 @@ RUN set -ex; \
8851
# LD_LIBRARY_PATH is empty by default, this is the first entry
8952
ENV LD_LIBRARY_PATH="/usr/lib/llvm-${LLVM_VERSION}/lib"
9053

91-
# Python setup
92-
# PYTHON_VERSION should match the value in .python-version
93-
ARG PYTHON_VERSION=3.9.18
94-
RUN apt-get update && apt-get install $APT_ARGS \
95-
ca-certificates \
96-
libbz2-dev \
97-
libffi-dev \
98-
liblzma-dev \
99-
libncurses5-dev \
100-
libncursesw5-dev \
101-
libreadline-dev \
102-
libsqlite3-dev \
103-
libssl-dev \
104-
make \
105-
tk-dev \
106-
xz-utils \
107-
&& rm -rf /var/lib/apt/lists/*
108-
109-
ENV PYENV_ROOT="/usr/local/pyenv"
110-
ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"
111-
RUN curl https://pyenv.run | bash \
112-
&& pyenv update \
113-
&& pyenv install $PYTHON_VERSION \
114-
&& pyenv global $PYTHON_VERSION \
115-
&& pyenv rehash
116-
RUN pip3 install --no-cache-dir \
117-
codespell==1.17.1 \
118-
flake8==3.8.3 \
119-
jinja2 \
120-
lief==0.13.2 \
121-
multiprocess \
122-
mypy==0.910 \
123-
pyzmq==22.3.0 \
124-
vulture==2.3
125-
126-
ARG DASH_HASH_VERSION=1.4.0
127-
RUN set -ex; \
128-
cd /tmp; \
129-
git clone --depth 1 --no-tags --branch=${DASH_HASH_VERSION} https://github.com/dashpay/dash_hash; \
130-
cd dash_hash && pip3 install -r requirements.txt .; \
131-
cd .. && rm -rf dash_hash
132-
13354
RUN set -ex; \
13455
git clone --depth=1 "https://github.com/include-what-you-use/include-what-you-use" -b "clang_${LLVM_VERSION}" /opt/iwyu; \
13556
cd /opt/iwyu; \
@@ -138,22 +59,6 @@ RUN set -ex; \
13859
make install -j "$(( $(nproc) - 1 ))"; \
13960
cd /opt && rm -rf /opt/iwyu;
14061

141-
ARG SHELLCHECK_VERSION=v0.7.1
142-
RUN set -ex; \
143-
curl -fL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" -o /tmp/shellcheck.tar.xz; \
144-
mkdir -p /opt/shellcheck && tar -xf /tmp/shellcheck.tar.xz -C /opt/shellcheck --strip-components=1 && rm /tmp/shellcheck.tar.xz
145-
ENV PATH="/opt/shellcheck:${PATH}"
146-
147-
# Setup unprivileged user and configuration files
148-
ARG USER_ID=1000 \
149-
GROUP_ID=1000
150-
RUN set -ex; \
151-
groupmod -g ${GROUP_ID} -n dash ubuntu; \
152-
usermod -u ${USER_ID} -md /home/dash -l dash ubuntu; \
153-
mkdir -p /home/dash/.config/gdb; \
154-
echo "add-auto-load-safe-path /usr/lib/llvm-${LLVM_VERSION}/lib" | tee /home/dash/.config/gdb/gdbinit; \
155-
chown ${USER_ID}:${GROUP_ID} -R /home/dash
156-
15762
# Packages needed for all target builds
15863
RUN apt-get update && apt-get install $APT_ARGS \
15964
bc \
@@ -171,7 +76,6 @@ RUN apt-get update && apt-get install $APT_ARGS \
17176
wine-stable \
17277
wine64 \
17378
zip \
174-
zstd \
17579
&& rm -rf /var/lib/apt/lists/*
17680

17781
# Make sure std::thread and friends is available
@@ -181,15 +85,11 @@ RUN \
18185
exit 0
18286

18387
RUN \
184-
mkdir -p /src/dash && \
18588
mkdir -p /cache/ccache && \
18689
mkdir /cache/depends && \
18790
mkdir /cache/sdk-sources && \
188-
chown ${USER_ID}:${GROUP_ID} /src && \
189-
chown ${USER_ID}:${GROUP_ID} -R /src && \
19091
chown ${USER_ID}:${GROUP_ID} /cache && \
19192
chown ${USER_ID}:${GROUP_ID} -R /cache
19293

193-
WORKDIR /src/dash
194-
94+
# We're done, switch back to non-privileged user
19595
USER dash

contrib/containers/develop/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ RUN set -ex; \
4141
#
4242
RUN groupadd docker && \
4343
usermod -aG sudo dash && \
44-
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
44+
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers; \
45+
mkdir -p /home/dash/.config/gdb; \
46+
echo "add-auto-load-safe-path /usr/lib/llvm-${LLVM_VERSION}/lib" | tee /home/dash/.config/gdb/gdbinit; \
47+
chown ${USER_ID}:${GROUP_ID} -R /home/dash
4548

4649
# Disable noninteractive mode
4750
ENV DEBIAN_FRONTEND="dialog"

0 commit comments

Comments
 (0)