Skip to content

Commit 05aca3a

Browse files
committed
feat(Dockerfile): install arch-specific versions of tools
1 parent e570d60 commit 05aca3a

1 file changed

Lines changed: 31 additions & 18 deletions

File tree

Dockerfile

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,22 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update
3939

4040
# j5j Turns JSON5 into plain old JSON (i.e. to be processed by jq).
4141
FROM apt-base as j5j
42-
ARG J5J_VERSION=v0.2.0 # repo=olix0r/j5j
43-
RUN url="https://github.com/olix0r/j5j/releases/download/${J5J_VERSION}/j5j-${J5J_VERSION}-x86_64-unknown-linux-musl.tar.gz" ; \
42+
ARG J5J_VERSION=v0.2.1 # repo=unleashed/j5j
43+
RUN arch=$(uname -m); \
44+
url="https://github.com/unleashed/j5j/releases/download/${J5J_VERSION}/j5j-${J5J_VERSION}-${arch}-unknown-linux-musl.tar.gz" ; \
4445
scurl "$url" | tar zvxf - -C /usr/local/bin j5j
4546

4647
# just runs build/test recipes. Like `make` but a bit more ergonomic.
4748
FROM apt-base as just
4849
ARG JUST_VERSION=1.43.0 # repo=casey/just
49-
RUN url="https://github.com/casey/just/releases/download/${JUST_VERSION}/just-${JUST_VERSION}-x86_64-unknown-linux-musl.tar.gz" ; \
50+
RUN url="https://github.com/casey/just/releases/download/${JUST_VERSION}/just-${JUST_VERSION}-$(uname -m)-unknown-linux-musl.tar.gz" ; \
5051
scurl "$url" | tar zvxf - -C /usr/local/bin just
5152

5253
# yq is kind of like jq, but for YAML.
5354
FROM apt-base as yq
5455
ARG YQ_VERSION=v4.47.2 # repo=mikefarah/yq
55-
RUN url="https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" ; \
56+
RUN arch=$(uname -m | sed -e 's/aarch/arm/' -e 's/x86_/amd/'); \
57+
url="https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${arch}" ; \
5658
scurl -o /yq "$url" && chmod +x /yq
5759

5860
FROM scratch as tools-script
@@ -68,20 +70,23 @@ COPY --link bin/scurl /bin/
6870
# helm templates kubernetes manifests.
6971
FROM apt-base as helm
7072
ARG HELM_VERSION=v3.19.0 # repo=helm/helm
71-
RUN url="https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz" ; \
72-
scurl "$url" | tar xzvf - --strip-components=1 -C /usr/local/bin linux-amd64/helm
73+
RUN arch=$(uname -m | sed -e 's/aarch/arm/' -e 's/x86_/amd/'); \
74+
url="https://get.helm.sh/helm-${HELM_VERSION}-linux-${arch}.tar.gz" ; \
75+
scurl "$url" | tar xzvf - --strip-components=1 -C /usr/local/bin linux-${arch}/helm
7376

7477

7578
# helm-docs generates documentation from helm charts.
7679
FROM apt-base as helm-docs
7780
ARG HELM_DOCS_VERSION=v1.14.2 # repo=norwoodj/helm-docs
78-
RUN url="https://github.com/norwoodj/helm-docs/releases/download/$HELM_DOCS_VERSION/helm-docs_${HELM_DOCS_VERSION#v}_Linux_x86_64.tar.gz" ; \
81+
RUN arch=$(uname -m | sed -e 's/aarch/arm/'); \
82+
url="https://github.com/norwoodj/helm-docs/releases/download/$HELM_DOCS_VERSION/helm-docs_${HELM_DOCS_VERSION#v}_Linux_${arch}.tar.gz" ; \
7983
scurl "$url" | tar xzvf - -C /usr/local/bin helm-docs
8084

8185
# kubectl controls kubernetes clusters.
8286
FROM apt-base as kubectl
8387
ARG KUBECTL_VERSION=v1.34.1 # repo=kubernetes/kubernetes
84-
RUN url="https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" ; \
88+
RUN arch=$(uname -m | sed -e 's/aarch/arm/'); \
89+
url="https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${arch}/kubectl" ; \
8590
scurl -o /usr/local/bin/kubectl "$url" && chmod +x /usr/local/bin/kubectl
8691

8792
# k3d runs kubernetes clusters in docker.
@@ -116,7 +121,8 @@ COPY --link --from=ghcr.io/anchore/grype:v0.96.1 /grype /bin/
116121
# actionlint lints github actions workflows.
117122
FROM apt-base as actionlint
118123
ARG ACTIONLINT_VERSION=v1.7.7 # repo=rhysd/actionlint
119-
RUN url="https://github.com/rhysd/actionlint/releases/download/${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION#v}_linux_amd64.tar.gz" ; \
124+
RUN arch=$(uname -m | sed -e 's/aarch/arm/' -e 's/x86_/amd/'); \
125+
url="https://github.com/rhysd/actionlint/releases/download/${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION#v}_linux_${arch}.tar.gz" ; \
120126
scurl "$url" | tar xzvf - -C /usr/local/bin actionlint
121127

122128
# checksec checks binaries for security issues.
@@ -137,7 +143,8 @@ COPY --link bin/action-* bin/just-dev bin/just-sh /bin/
137143

138144
FROM apt-base as protobuf
139145
ARG PROTOC_VERSION=v32.1 # repo=protocolbuffers/protobuf
140-
RUN url="https://github.com/google/protobuf/releases/download/$PROTOC_VERSION/protoc-${PROTOC_VERSION#v}-linux-$(uname -m).zip" ; \
146+
RUN arch=$(uname -m | sed -e 's/aarch/aarch_/'); \
147+
url="https://github.com/google/protobuf/releases/download/$PROTOC_VERSION/protoc-${PROTOC_VERSION#v}-linux-${arch}.zip" ; \
141148
cd $(mktemp -d) && \
142149
scurl -o protoc.zip "$url" && \
143150
unzip protoc.zip bin/protoc include/** && \
@@ -153,30 +160,36 @@ RUN url="https://github.com/google/protobuf/releases/download/$PROTOC_VERSION/pr
153160
# cargo-action-fmt formats `cargo build` JSON output to Github Actions annotations.
154161
FROM apt-base as cargo-action-fmt
155162
ARG CARGO_ACTION_FMT_VERSION=v1.0.4 # ignore
156-
RUN url="https://github.com/olix0r/cargo-action-fmt/releases/download/release%2F${CARGO_ACTION_FMT_VERSION}/cargo-action-fmt-${CARGO_ACTION_FMT_VERSION}-x86_64-unknown-linux-musl.tar.gz" ; \
163+
RUN arch=$(uname -m); \
164+
url="https://github.com/olix0r/cargo-action-fmt/releases/download/release%2F${CARGO_ACTION_FMT_VERSION}/cargo-action-fmt-${CARGO_ACTION_FMT_VERSION}-${arch}-unknown-linux-musl.tar.gz" ; \
157165
scurl "$url" | tar zvxf - -C /usr/local/bin cargo-action-fmt
158166

159167
FROM apt-base as cargo-auditable
160-
ARG CARGO_AUDITABLE_VERSION=v0.6.6 # repo=rust-secure-code/cargo-auditable
161-
RUN url="https://github.com/rust-secure-code/cargo-auditable/releases/download/${CARGO_AUDITABLE_VERSION}/cargo-auditable-x86_64-unknown-linux-gnu.tar.xz" ; \
162-
scurl "$url" | tar xJvf - --strip-components=1 -C /usr/local/bin cargo-auditable-x86_64-unknown-linux-gnu/cargo-auditable
168+
ARG CARGO_AUDITABLE_VERSION=v0.7.2 # repo=rust-secure-code/cargo-auditable
169+
RUN arch=$(uname -m); \
170+
libc=$([ "$arch" = "x86_64" ] && echo "musl" || echo "gnu"); \
171+
url="https://github.com/rust-secure-code/cargo-auditable/releases/download/${CARGO_AUDITABLE_VERSION}/cargo-auditable-${arch}-unknown-linux-${libc}.tar.xz" ; \
172+
scurl "$url" | tar xJvf - --strip-components=1 -C /usr/local/bin cargo-auditable-${arch}-unknown-linux-${libc}/cargo-auditable
163173

164174
# cargo-deny checks cargo dependencies for licensing and RUSTSEC security issues.
165175
FROM apt-base as cargo-deny
166176
ARG CARGO_DENY_VERSION=0.18.5 # repo=EmbarkStudios/cargo-deny
167-
RUN url="https://github.com/EmbarkStudios/cargo-deny/releases/download/${CARGO_DENY_VERSION}/cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl.tar.gz" ; \
168-
scurl "$url" | tar zvxf - --strip-components=1 -C /usr/local/bin "cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl/cargo-deny"
177+
RUN arch=$(uname -m); \
178+
url="https://github.com/EmbarkStudios/cargo-deny/releases/download/${CARGO_DENY_VERSION}/cargo-deny-${CARGO_DENY_VERSION}-${arch}-unknown-linux-musl.tar.gz" ; \
179+
scurl "$url" | tar zvxf - --strip-components=1 -C /usr/local/bin "cargo-deny-${CARGO_DENY_VERSION}-${arch}-unknown-linux-musl/cargo-deny"
169180

170181
# cargo-nextest is a nicer test runner.
171182
FROM apt-base as cargo-nextest
172183
ARG NEXTEST_VERSION=0.9.104 # repo=nextest-rs/nextest,prefix=cargo-nextest-
173-
RUN url="https://github.com/nextest-rs/nextest/releases/download/cargo-nextest-${NEXTEST_VERSION}/cargo-nextest-${NEXTEST_VERSION}-x86_64-unknown-linux-gnu.tar.gz" ; \
184+
RUN arch=$(uname -m); \
185+
url="https://github.com/nextest-rs/nextest/releases/download/cargo-nextest-${NEXTEST_VERSION}/cargo-nextest-${NEXTEST_VERSION}-${arch}-unknown-linux-gnu.tar.gz" ; \
174186
scurl "$url" | tar zvxf - -C /usr/local/bin cargo-nextest
175187

176188
# cargo-tarpaulin is a code coverage tool.
177189
FROM apt-base as cargo-tarpaulin
178190
ARG CARGO_TARPAULIN_VERSION=0.32.8 # repo=xd009642/tarpaulin
179-
RUN url="https://github.com/xd009642/tarpaulin/releases/download/${CARGO_TARPAULIN_VERSION}/cargo-tarpaulin-x86_64-unknown-linux-musl.tar.gz" ;\
191+
RUN arch=$(uname -m); \
192+
url="https://github.com/xd009642/tarpaulin/releases/download/${CARGO_TARPAULIN_VERSION}/cargo-tarpaulin-${arch}-unknown-linux-musl.tar.gz" ;\
180193
scurl "$url" | tar xzvf - -C /usr/local/bin cargo-tarpaulin
181194

182195
FROM scratch as tools-rust

0 commit comments

Comments
 (0)