Question: how to use a shell variable inside another eval block
I want to evaluate a variable conditionally for use in my docker image build
RUN ARCHFLAG="$(uname -m)" && ARCH=$([ $ARCHFLAG == "aarch64" ] && echo "arm64" || echo $ARCHFLAG) && curl -sL "https://get.helm.sh/helm-v${HELM_VERSION}-linux-${ARCH}.tar.gz" | tar -xvz && \ mv linux-${ARCH}/helm /usr/bin/helm && \ chmod +x /usr/bin/helm && \ rm -rf linux-${ARCH}
I get the error
------ > [ 5/13] RUN ARCHFLAG="$(uname -m)" && ARCH=$([ ARCHFLAG == "aarch64"] && echo "arm64" || echo $ARCHFLAG) && curl -sL "https://get.helm.sh/helm-v3.6.3-linux-${ARCH}.tar.gz" | tar -xvz && mv linux-${ARCH}/helm /usr/bin/helm && chmod +x /usr/bin/helm && rm -rf linux-${ARCH}: #8 0.248 /bin/sh: 1: [: aarch64: unexpected operator #8 1.295 #8 1.295 gzip: stdin: not in gzip format #8 1.296 tar: Child returned status 1 #8 1.296 tar: Error is not recoverable: exiting now
I've enclosing it as a string too, in the IDE the first $ARCHFLAG
shows up in the same colours as rest of the strings while the second $ARXCHFLAG
does show up as variable.