Skip to content

Commit e7aec51

Browse files
authored
chore: verify xwin checksum (#1099)
* chore: verify xwin checksum * chore: silence linter warnings * chore: retry ignore * chore: maybe this works * chore: another permutation * chore: one last try before global ignore * chore: the ignore bazooka * chore: process review comments
1 parent 5d8ba52 commit e7aec51

1 file changed

Lines changed: 52 additions & 11 deletions

File tree

.devcontainer/cpp/Dockerfile

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,47 @@
11
# syntax=docker/dockerfile:1
2+
# hadolint global ignore=DL3006
23

34
ARG BASE_IMAGE=ghcr.io/philips-software/amp-devcontainer-base:edge
5+
ARG XWIN_VERSION=0.7.0
6+
7+
# Downloader stage for AMD64 architecture
8+
FROM scratch AS downloader-amd64
9+
10+
ARG XWIN_VERSION
11+
12+
ADD --checksum=sha256:f1bffe5319728fca9cde5bb03fcb6c88cdf44922bd003fca8b4b9ce5b6f259d2 \
13+
https://github.com/Jake-Shadle/xwin/releases/download/${XWIN_VERSION}/xwin-${XWIN_VERSION}-x86_64-unknown-linux-musl.tar.gz /xwin.tar.gz
14+
15+
# Downloader stage for ARM64 architecture
16+
FROM scratch AS downloader-arm64
17+
18+
ARG XWIN_VERSION
19+
20+
ADD --checksum=sha256:b85cd1e0c94f249338b02a6e54b380154a5af6b5dd754121b15722125a67cf9f \
21+
https://github.com/Jake-Shadle/xwin/releases/download/${XWIN_VERSION}/xwin-${XWIN_VERSION}-aarch64-unknown-linux-musl.tar.gz /xwin.tar.gz
22+
23+
# Select downloader stage based on target architecture.
24+
# Linters don't recognize the TARGETARCH variable, so we ignore warnings here.
25+
# trivy:ignore:AVD-DS-0001
26+
FROM downloader-${TARGETARCH} AS downloader
27+
28+
# Extractor stage using target architecture specific downloader
29+
FROM ${BASE_IMAGE} AS extractor
30+
31+
ARG XWIN_VERSION
32+
33+
WORKDIR /
34+
35+
RUN --mount=from=downloader,target=/dl \
36+
tar xzf /dl/xwin.tar.gz --strip-components=1 "xwin-${XWIN_VERSION}-$(uname -m)-unknown-linux-musl/xwin"
37+
38+
# Final development container image
439
FROM ${BASE_IMAGE}
540

641
ARG CCACHE_VERSION=4.12
742
ARG CLANG_VERSION=19
843
ARG CPM_VERSION=0.40.2
944
ARG INCLUDE_WHAT_YOU_USE_VERSION=0.23
10-
ARG XWIN_VERSION=0.6.7
1145

1246
ARG DEBIAN_FRONTEND=noninteractive
1347

@@ -24,20 +58,28 @@ ENV CCACHE_DIR=/cache/.ccache \
2458
PATH="$PATH:/usr/lib/llvm-${CLANG_VERSION}/bin:/opt/gcc-arm-none-eabi/bin" \
2559
PYTHONPYCACHEPREFIX=/cache/.python
2660

27-
# Install the base system with all tool dependencies
2861
# hadolint ignore=DL3008
2962
RUN --mount=type=bind,source=.devcontainer/cpp/apt-requirements-base.json,target=/tmp/apt-requirements-base.json \
3063
--mount=type=bind,source=.devcontainer/cpp/requirements.txt,target=/tmp/requirements.txt \
3164
--mount=type=cache,target=/cache,sharing=locked \
3265
--mount=type=cache,target=/var/cache/apt,sharing=locked \
3366
--mount=type=cache,target=/var/lib/apt,sharing=locked \
3467
--mount=type=cache,target=/var/log,sharing=locked \
35-
apt-get update \
36-
&& jq -r 'to_entries | .[] | .key + "=" + .value' /tmp/apt-requirements-base.json | xargs apt-get install -y --no-install-recommends \
37-
# Install some tools via pip to get more recent versions, clean up afterwards
38-
&& python3 -m pip install --break-system-packages --require-hashes --no-cache-dir --no-compile -r /tmp/requirements.txt \
39-
&& find / -regex '^.*\(__pycache__\|\.py[co]\)$' -delete \
40-
&& rm -rf "$(pip cache dir)"
68+
--mount=from=extractor,target=/src <<EOF
69+
70+
# Install the base system with all tool dependencies
71+
apt-get update && \
72+
jq -r 'to_entries | .[] | .key + "=" + .value' /tmp/apt-requirements-base.json | \
73+
xargs apt-get install -y --no-install-recommends
74+
75+
# Install some tools via pip to get more recent versions, clean up afterwards
76+
python3 -m pip install --break-system-packages --require-hashes --no-cache-dir --no-compile -r /tmp/requirements.txt
77+
find / -regex '^.*\(__pycache__\|\.py[co]\)$' -delete
78+
rm -rf "$(pip cache dir)"
79+
80+
# Install xwin
81+
cp /src/xwin /usr/local/bin/xwin
82+
EOF
4183

4284
# Install clang toolchain and mull mutation testing framework
4385
RUN --mount=type=bind,source=.devcontainer/cpp/apt-requirements-clang.json,target=/tmp/apt-requirements-clang.json \
@@ -57,9 +99,8 @@ RUN --mount=type=bind,source=.devcontainer/cpp/apt-requirements-clang.json,targe
5799
RUN mkdir /opt/gcc-arm-none-eabi \
58100
&& wget --no-hsts -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
59101

60-
# Install xwin and ccache
61-
RUN wget --no-hsts -qO - "https://github.com/Jake-Shadle/xwin/releases/download/${XWIN_VERSION}/xwin-${XWIN_VERSION}-$(uname -m)-unknown-linux-musl.tar.gz" | tar -xzv -C /usr/local/bin --strip-components=1 "xwin-${XWIN_VERSION}-$(uname -m)-unknown-linux-musl/xwin" \
62-
&& wget --no-hsts -qO - "https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-linux-$(uname -m).tar.xz" | tar -xJ -C /usr/local/bin --strip-components=1 "ccache-${CCACHE_VERSION}-linux-$(uname -m)/ccache"
102+
# Install ccache
103+
RUN wget --no-hsts -qO - "https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-linux-$(uname -m).tar.xz" | tar -xJ -C /usr/local/bin --strip-components=1 "ccache-${CCACHE_VERSION}-linux-$(uname -m)/ccache"
63104

64105
# Install include-what-you-use (iwyu) from source
65106
# hadolint ignore=DL3008

0 commit comments

Comments
 (0)