Skip to content
Draft
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
41e6ff7
chore: reduce COPY's and wget's
rjaegers Jun 2, 2025
8624c61
chore: fix build issue
rjaegers Jun 2, 2025
0b2e86f
chore: test-drive multi-stage downloads
rjaegers Jun 2, 2025
ca8c04b
chore: fix warnings and build error
rjaegers Jun 2, 2025
620626a
chore: more fixing
rjaegers Jun 2, 2025
9188d3f
chore: move extraction of archive
rjaegers Jun 2, 2025
73cfe9a
chore: fix arg reference
rjaegers Jun 2, 2025
7af1004
chore: re-fix arg usage
rjaegers Jun 2, 2025
5114443
chore: fix extraction
rjaegers Jun 2, 2025
c6fd52e
chore: squash another layer
rjaegers Jun 2, 2025
5831465
chore: add checksums to gpg keys
rjaegers Jun 2, 2025
f389335
chore: fix line continuation
rjaegers Jun 2, 2025
eafb9d5
chore: fix an "it was late"
rjaegers Jun 3, 2025
4a88582
chore: correct installation of certificate
rjaegers Jun 3, 2025
a45aba4
chore: move download of arm gcc toolchain to separate stage
rjaegers Jun 3, 2025
a1d0653
chore: fix gcc-arm-none-eabi install
rjaegers Jun 3, 2025
a448ac3
chore: hoist-up xwin as well
rjaegers Jun 3, 2025
0e504ff
chore: hoist-up bats installation
rjaegers Jun 3, 2025
d92864e
chore: reduce number of layers
rjaegers Jun 3, 2025
b9daef1
Merge branch 'main' into feature/reduce-unnecessary-copy-and-wget
rjaegers Jun 6, 2025
f906441
Merge branch 'main' into feature/reduce-unnecessary-copy-and-wget
rjaegers Jun 10, 2025
4372863
Merge branch 'main' into feature/reduce-unnecessary-copy-and-wget
rjaegers Jun 19, 2025
5a8e0b4
Merge branch 'main' into feature/reduce-unnecessary-copy-and-wget
rjaegers Jun 26, 2025
f761eb4
Merge branch 'main' into feature/reduce-unnecessary-copy-and-wget
rjaegers Jun 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 56 additions & 29 deletions .devcontainer/cpp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
# syntax=docker/dockerfile:1

FROM scratch AS downloader-amd64
ADD --checksum=sha256:53dc06dc3f775282ddff93b2d0974bbe6480761018c61e7a797342a9c7f14e23 \
https://download.docker.com/linux/static/stable/x86_64/docker-28.2.2.tgz /docker.tgz
ADD --checksum=sha256:62a63b981fe391a9cbad7ef51b17e49aeaa3e7b0d029b36ca1e9c3b2a9b78823 \
https://developer.arm.com/-/media/Files/downloads/gnu/14.2.rel1/binrel/arm-gnu-toolchain-14.2.rel1-x86_64-arm-none-eabi.tar.xz /arm-gnu-toolchain.tar.xz

FROM scratch AS downloader-arm64
ADD --checksum=sha256:c9506628d1845c69230df3d87e2eedd7980caf8bd966f5e6a5d7a2364de42497 \
https://download.docker.com/linux/static/stable/aarch64/docker-28.2.2.tgz /docker.tgz
ADD --checksum=sha256:87330bab085dd8749d4ed0ad633674b9dc48b237b61069e3b481abd364d0a684 \
https://developer.arm.com/-/media/Files/downloads/gnu/14.2.rel1/binrel/arm-gnu-toolchain-14.2.rel1-aarch64-arm-none-eabi.tar.xz /arm-gnu-toolchain.tar.xz

FROM downloader-$TARGETARCH AS downloader

Check warning

Code scanning / Trivy (MegaLinter REPOSITORY_TRIVY)

':latest' tag used Medium

Artifact: .devcontainer/cpp/Dockerfile
Type: dockerfile
Vulnerability DS001
Severity: MEDIUM
Message: Specify a tag in the 'FROM' statement for image 'downloader-'
Link: DS001
ADD --checksum=sha256:ce6eee4130298f79b0e0f09a89f93c1bc711cd68e7e3182d37c8e96c5227e2f0 \
https://apt.llvm.org/llvm-snapshot.gpg.key /llvm.gpg.key
ADD --checksum=sha256:db2938ce5fd422f2db7a07508452772c945135d99274004c462190c323fefcf1 \
https://dl.cloudsmith.io/public/mull-project/mull-stable/gpg.41DB35380DE6BD6F.key /mull.gpg.key

FROM ubuntu:24.04@sha256:6015f66923d7afbc53558d7ccffd325d43b4e249f41a6e93eef074c9505d2233 AS extractor

WORKDIR /tmp

# hadolint ignore=DL3008
RUN --mount=from=downloader,target=/dl \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends xz-utils \
&& tar xzf /dl/docker.tgz \
&& tar xJf /dl/arm-gnu-toolchain.tar.xz --exclude='*arm-none-eabi-gdb*' --exclude='share' \
&& mv arm-gnu-toolchain-*/ gcc-arm-none-eabi

FROM ubuntu:24.04@sha256:6015f66923d7afbc53558d7ccffd325d43b4e249f41a6e93eef074c9505d2233

ARG BATS_VERSION=1.11.0
ARG CCACHE_VERSION=4.11
ARG CLANG_VERSION=18
ARG CPM_VERSION=0.40.2
ARG DOCKER_VERSION=27.3.1
ARG INCLUDE_WHAT_YOU_USE_VERSION=0.22
ARG XWIN_VERSION=0.6.5

Expand All @@ -14,22 +46,22 @@

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Install the base system with all tool dependencies
COPY .devcontainer/cpp/apt-requirements-base.json /tmp/apt-requirements-base.json
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends jq \
&& jq -r 'to_entries | .[] | .key + "=" + .value' /tmp/apt-requirements-base.json | xargs apt-get install -y --no-install-recommends \
&& rm /tmp/apt-requirements-base.json \
&& rm -rf /var/lib/apt/lists/*

# Include the Cisco Umbrella PKI Root
RUN wget -qO /usr/local/share/ca-certificates/Cisco_Umbrella_Root_CA.crt https://www.cisco.com/security/pki/certs/ciscoumbrellaroot.pem \
&& update-ca-certificates
ADD --checksum=sha256:a122d4080a26c1da986bd0e7202b1630eb661a624915ef244f496fdd306e85fb \
https://www.cisco.com/security/pki/certs/ciscoumbrellaroot.pem /usr/local/share/ca-certificates/cisco-umbrella.crt

# Install some tools via pip to get more recent versions
COPY .devcontainer/cpp/requirements.txt /tmp/requirements.txt
RUN python3 -m pip install --break-system-packages --require-hashes --no-cache-dir -r /tmp/requirements.txt \
&& rm -rf /tmp/requirements.txt
# Install the base system with all tool dependencies
# Some tools are installed via pip to get more recent versions
# hadolint ignore=DL3008
RUN --mount=type=bind,source=.devcontainer/cpp/apt-requirements-base.json,target=/tmp/apt-requirements-base.json \
--mount=type=bind,source=.devcontainer/cpp/requirements.txt,target=/tmp/requirements.txt \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends jq \
&& jq -r 'to_entries | .[] | .key + "=" + .value' /tmp/apt-requirements-base.json | \
xargs apt-get install -y --no-install-recommends \
&& update-ca-certificates \
&& python3 -m pip install --break-system-packages --require-hashes --no-cache-dir -r /tmp/requirements.txt

# Set default environment options for CMake and ccache
ENV CMAKE_GENERATOR="Ninja"
Expand All @@ -38,29 +70,24 @@
ENV CPM_SOURCE_CACHE=/cache/.cpm-cache

# Install clang toolchain and mull mutation testing framework
COPY .devcontainer/cpp/apt-requirements-clang.json /tmp/apt-requirements-clang.json
# hadolint ignore=SC1091
RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-snapshot-keyring.gpg \
&& wget -qO - https://dl.cloudsmith.io/public/mull-project/mull-stable/gpg.41DB35380DE6BD6F.key | gpg --dearmor -o /usr/share/keyrings/mull-project-mull-stable-archive-keyring.gpg \
RUN --mount=type=bind,source=.devcontainer/cpp/apt-requirements-clang.json,target=/tmp/apt-requirements-clang.json \
--mount=from=downloader,target=/keys \
cat /keys/llvm.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-snapshot-keyring.gpg \
&& cat /keys/mull.gpg.key | gpg --dearmor -o /usr/share/keyrings/mull-project-mull-stable-archive-keyring.gpg \
&& UBUNTU_CODENAME=$(. /etc/os-release; echo "${UBUNTU_CODENAME/*, /}") \
&& echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot-keyring.gpg] http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-${CLANG_VERSION} main" | tee /etc/apt/sources.list.d/llvm.list > /dev/null \
&& echo "deb [signed-by=/usr/share/keyrings/mull-project-mull-stable-archive-keyring.gpg] https://dl.cloudsmith.io/public/mull-project/mull-stable/deb/ubuntu ${UBUNTU_CODENAME} main" | tee /etc/apt/sources.list.d/mull-project-mull-stable.list > /dev/null \
&& echo -e 'Package: *\nPin: origin "apt.llvm.org"\nPin-Priority: 1000' > /etc/apt/preferences \
&& apt-get update \
&& jq -r 'to_entries | .[] | .key + "=" + .value' /tmp/apt-requirements-clang.json | xargs apt-get install -y --no-install-recommends \
&& rm /tmp/apt-requirements* \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/cache/apt/archives /var/lib/apt/lists/*
ENV PATH="$PATH:/usr/lib/llvm-${CLANG_VERSION}/bin"

# Install arm-gcc toolchain
RUN mkdir /opt/gcc-arm-none-eabi \
&& wget -qO - "https://developer.arm.com/-/media/Files/downloads/gnu/14.2.rel1/binrel/arm-gnu-toolchain-14.2.rel1-$(uname -m)-arm-none-eabi.tar.xz" | tar --exclude='*arm-none-eabi-gdb*' --exclude='share' --strip-components=1 -xJC /opt/gcc-arm-none-eabi
ENV PATH="$PATH:/opt/gcc-arm-none-eabi/bin"

# Install docker-cli for Docker-from-Docker tools
RUN wget -qO - "https://download.docker.com/linux/static/stable/$(uname -m)/docker-${DOCKER_VERSION}.tgz" | tar xz -C /tmp \
&& mv /tmp/docker/docker /usr/local/bin/ \
&& rm -rf /tmp/docker
# Copy tools from the extractor stage
COPY --from=extractor /tmp/docker/docker /usr/local/bin
COPY --from=extractor /tmp/gcc-arm-none-eabi /opt/gcc-arm-none-eabi

# Install bats
RUN batstmp="$(mktemp -d /tmp/bats-core-${BATS_VERSION}.XXXX)" \
Expand Down Expand Up @@ -88,7 +115,7 @@
&& CC=clang CXX=clang++ cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -S /tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION} -B /tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION}/build \
&& cmake --build /tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION}/build --target install \
&& rm -rf /tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION} \
&& apt-get purge -y libclang-${CLANG_VERSION}-dev llvm-${CLANG_VERSION}-dev libsqlite3-dev \
&& apt-get purge -y libclang-${CLANG_VERSION}-dev llvm-${CLANG_VERSION}-dev \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
Expand Down
3 changes: 1 addition & 2 deletions .devcontainer/cpp/apt-requirements-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
"udev": "255.4-1ubuntu8.6",
"unzip": "6.0-28ubuntu4.1",
"wget": "1.21.4-1ubuntu4.1",
"xsltproc": "1.1.39-0exp1ubuntu0.24.04.2",
"xz-utils": "5.6.1+really5.4.5-1ubuntu0.2"
"xsltproc": "1.1.39-0exp1ubuntu0.24.04.2"
}
2 changes: 1 addition & 1 deletion .devcontainer/cpp/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"forwardPorts": [6080],
"remoteEnv": {
"CONTAINER_FLAVOR": "cpp",
"NODE_EXTRA_CA_CERTS": "/usr/local/share/ca-certificates/Cisco_Umbrella_Root_CA.crt"
"NODE_EXTRA_CA_CERTS": "/usr/local/share/ca-certificates/cisco-umbrella.crt"
},
"mounts": [
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
Expand Down
Loading