Skip to content

Instantly share code, notes, and snippets.

@hongkongkiwi
Created October 19, 2020 08:25
Show Gist options
  • Save hongkongkiwi/48338255bde9f3f4160f6cd532bc89bc to your computer and use it in GitHub Desktop.
Save hongkongkiwi/48338255bde9f3f4160f6cd532bc89bc to your computer and use it in GitHub Desktop.
Dockerfile snippet to detect platform arch
FROM ubuntu:latest
ARG PLATFORM_ARCH=
RUN case "$(uname -m)" in \
x86_32) export PLATFORM_ARCH='386' ;; \
x86_64) export PLATFORM_ARCH='amd64' ;; \
amd64) export PLATFORM_ARCH='amd64' ;; \
armhf) export PLATFORM_ARCH='arm' ;; \
armv7) export PLATFORM_ARCH='arm' ;; \
aarch64) export PLATFORM_ARCH='arm64' ;; \
arm64) export PLATFORM_ARCH='arm64' ;; \
*) echo >&2 "error: unsupported architecture ($PLATFORM_ARCH)"; exit 1 ;; \
esac; \
echo "Detected System Architecture \"$PLATFORM_ARCH\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment