Skip to content

Commit a58f475

Browse files
authored
Add sha256 validation for binaries in Dockerfile (#197)
1 parent 8687a52 commit a58f475

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ ARG DENO_DIR='/deno-dir' \
1212
HOST='0.0.0.0' \
1313
PORT='8282'
1414

15+
# sha256 checksums for binaries
16+
ARG THC_SHA256='cb1797948015da46c222764a99ee30c06a6a9a30f5b87f212a28ea3c6d07610d' \
17+
TINI_SHA256='93dcc18adc78c65a028a84799ecf8ad40c936fdfc5f2a57b1acda5a8117fa82c'
1518

1619
# we can use these aliases and let dependabot remain simple
1720
# inspired by:
@@ -35,11 +38,12 @@ RUN DEBIAN_FRONTEND='noninteractive' && export DEBIAN_FRONTEND && \
3538

3639
# Download tiny-health-checker from GitHub
3740
FROM debian-curl AS thc-download
38-
ARG GH_BASE_URL THC_VERSION
41+
ARG GH_BASE_URL THC_VERSION THC_SHA256
3942
RUN arch="$(uname -m)" && \
4043
gh_url() { printf -- "${GH_BASE_URL}/%s/releases/download/%s/%s\n" "$@" ; } && \
4144
URL="$(gh_url dmikusa/tiny-health-checker v${THC_VERSION} tiny-health-checker-${arch}-unknown-linux-musl.tar.xz)" && \
4245
curl -fsSL --output /tiny-health-checker-${arch}-unknown-linux-musl.tar.xz "${URL}" && \
46+
echo "${THC_SHA256} /tiny-health-checker-${arch}-unknown-linux-musl.tar.xz" | sha256sum -c && \
4347
tar -xvf /tiny-health-checker-${arch}-unknown-linux-musl.tar.xz && \
4448
mv /tiny-health-checker-${arch}-unknown-linux-musl/thc /thc && \
4549
chmod -v 00555 /thc
@@ -52,11 +56,13 @@ COPY --from=thc-download /thc /thc
5256

5357
# Download tini from GitHub
5458
FROM debian-curl AS tini-download
55-
ARG GH_BASE_URL TINI_VERSION
59+
ARG GH_BASE_URL TINI_VERSION TINI_SHA256
5660
RUN arch="$(dpkg --print-architecture)" && \
5761
gh_url() { printf -- "${GH_BASE_URL}/%s/releases/download/%s/%s\n" "$@" ; } && \
5862
URL="$(gh_url krallin/tini v${TINI_VERSION} tini-${arch})" && \
59-
curl -fsSL --output /tini "${URL}" && chmod -v 00555 /tini
63+
curl -fsSL --output /tini "${URL}" && \
64+
echo "${TINI_SHA256} /tini" | sha256sum -c && \
65+
chmod -v 00555 /tini
6066

6167
# Cache the tini binary as a layer
6268
FROM scratch AS tini-bin

0 commit comments

Comments
 (0)