Fix architecture detection in kiwix-serve and kubectl Dockerfiles
Some checks failed
Build Container / build (push) Failing after 12s

TARGETARCH/TARGETPLATFORM are only set when using docker buildx.
Fall back to uname -m detection for plain docker build.
This commit is contained in:
Erich Blume 2026-01-25 21:04:58 -08:00
commit b3c59b1dd0
2 changed files with 33 additions and 7 deletions

View file

@ -8,13 +8,27 @@ ARG KIWIX_VERSION=3.8.1
RUN set -e && \
apk --no-cache add dumb-init curl && \
echo "TARGETPLATFORM: $TARGETPLATFORM" && \
if [ "$TARGETPLATFORM" = "linux/arm64/v8" -o "$TARGETPLATFORM" = "linux/arm64" ]; then \
ARCH="aarch64"; \
elif [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
ARCH="x86_64"; \
# Detect architecture - use TARGETPLATFORM if set, otherwise detect from uname
if [ -n "$TARGETPLATFORM" ]; then \
echo "TARGETPLATFORM: $TARGETPLATFORM"; \
case "$TARGETPLATFORM" in \
linux/arm64*) ARCH="aarch64" ;; \
linux/amd64*) ARCH="x86_64" ;; \
*) ARCH="" ;; \
esac; \
else \
ARCH="unknown"; \
echo "TARGETPLATFORM not set, detecting from uname..."; \
UNAME_ARCH=$(uname -m); \
echo "uname -m: $UNAME_ARCH"; \
case "$UNAME_ARCH" in \
aarch64|arm64) ARCH="aarch64" ;; \
x86_64) ARCH="x86_64" ;; \
*) ARCH="" ;; \
esac; \
fi && \
if [ -z "$ARCH" ]; then \
echo "ERROR: Unsupported architecture"; \
exit 1; \
fi && \
url="http://mirror.download.kiwix.org/release/kiwix-tools/kiwix-tools_linux-$ARCH-$KIWIX_VERSION.tar.gz" && \
echo "URL: $url" && \

View file

@ -7,7 +7,19 @@ ARG TARGETARCH
ARG KUBECTL_VERSION=v1.34.1
RUN apk add --no-cache curl && \
curl -LO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${TARGETARCH}/kubectl" && \
# Detect architecture - use TARGETARCH if set, otherwise detect from uname
if [ -n "$TARGETARCH" ]; then \
ARCH="$TARGETARCH"; \
else \
UNAME_ARCH=$(uname -m); \
case "$UNAME_ARCH" in \
aarch64|arm64) ARCH="arm64" ;; \
x86_64) ARCH="amd64" ;; \
*) echo "Unsupported architecture: $UNAME_ARCH"; exit 1 ;; \
esac; \
fi && \
echo "Downloading kubectl for $ARCH..." && \
curl -LO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${ARCH}/kubectl" && \
chmod +x kubectl
FROM alpine:3.21