1
RUN if [ "$AUTH_MS_PROFILE" = "test" ]; then RUN ["mvn", "verify"]; fi

so, the case is am trying to have two images for prod and test since I don't need to run integration test @ prod so, am using build-arg to set dev and test profile I need to have an if loop if the input is test it should test else it shouldn't

Derlin
  • 9,572
  • 2
  • 32
  • 53
Ajay
  • 33
  • 3
  • 9
  • so, did you try ? what is the problem ? – Derlin Sep 06 '17 at 08:15
  • Possible duplicate of [Dockerfile if else condition with external arguments](https://stackoverflow.com/questions/43654656/dockerfile-if-else-condition-with-external-arguments) – Derlin Sep 06 '17 at 08:17

1 Answers1

3

I would move all such conditions to a build_internal.sh file

if [ "$AUTH_MS_PROFILE" = "test" ]; then 
   mvn verify
fi

Copy this file inside and run it inside the Dockerfile. If you want to use your approach then you just need to use

RUN if [ "$AUTH_MS_PROFILE" = "test" ]; then mvn verify ; fi
Tarun Lalwani
  • 142,312
  • 9
  • 204
  • 265
  • At seem cleaner to keep all the configuration in the docker file rather than putting some in a bash script, so i am curious about the reasoning behind this. Do docker files not support loops, or is this considered a better way of doing things? – wobbily_col Feb 11 '19 at 10:44
  • @wobbily_col, that depends on how readable your conditions are – Tarun Lalwani Feb 12 '19 at 09:24