I have a Dockerfile and I want to do different things based on a build argument to determine isDev or not.
In the Dockerfile, I have:
ARG isDev
RUN echo "what is in isDev ? $isDev"
RUN if ["${isDev}" = "1"] ;
then ..... do dev stuff .... ;
else .... do production stuff ;
fi
I am building with my --build-arg isDev=1
Step 14/25 : ARG isDev
---> Running in 0a3de5fea466
Removing intermediate container 0a3de5fea466
---> a6d79a08a97e
Step 15/25 : RUN echo "what is in isDev ? $isDev"
---> Running in 92235e8b0c6a
what is in isDev ? 1
Removing intermediate container 92235e8b0c6a
---> a7b064687480
Step 16/25 : RUN if ["${isDev}" = "1"] ; then ... do dev stuff ... ; else ... do production stuff ... ; fi
---> Running in bbe6a047705a
[91m/bin/sh: 1: [1: not found
What am I doing wrong?
You're not going to like this answer, you're missing a space after [. You'll need another space before the closing bracket, and you need to escape the linefeeds. At least that's what I'm seeing at first glance.
ARG isDev
RUN echo "what is in isDev ? $isDev"
RUN if [ "${isDev}" = "1" ] ; \
then ..... do dev stuff .... ; \
else .... do production stuff ; \
fi
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