I'm trying to set a variable in a RUN
command and use it in the next RUN
command.
Depending on the TARGETARCH
arg, I'm trying to set PROTOC_ARCH
variable and use it in the next RUN
command to download a architecture specific file. But the variable isn't passing through. If I print the variable, it's always empty.
FROM ubuntu
ARG TARGETARCH="arm64"
ENV PROTOC_ARCH=""
RUN if [ "$TARGETARCH" = "arm64" ]; then \
PROTOC_ARCH="aarch_64"; \
else \
PROTOC_ARCH="x86_64"; \
fi
RUN apt-get update && apt-get install -y wget
RUN echo "PROTOC_ARCH=$PROTOC_ARCH"
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v22.2/protoc-22.2-linux-$PROTOC_ARCH.zip
Can anyone please tell me what I'm doing wrong here ?
Thanks in advance.