I want to download an sdk depending on the OS type my docker image is running on. How can I write the below pseudo code in docker script
RUN variable x = getOS()
if [ "$x" = "Darwin" ]; then
RUN wget -q http://xxx/android-ndk-xxxx-darwin-x86_64.bin
else
RUN wget -q http://xxx/android-ndk-xxxx-linux-x86_64.bin
Use the uname
command.
x=$(uname)
On a darwin system, it should output Darwin
.
In your dockerfile, the RUN command then could look like this:
RUN [ "$(uname)" = Darwin ] && system=darwin || system=linux; \
wget -q http://xxx/android-ndk-xxxx-${system}-x86_64.bin
Or like this (in order to support arbitrary systems):
RUN system=$(uname); \
wget -q http://xxx/android-ndk-xxxx-${system,}-x86_64.bin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With