Ajay
Ajay

Reputation: 33

using if loop in docker file

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

Upvotes: 1

Views: 2727

Answers (1)

Tarun Lalwani
Tarun Lalwani

Reputation: 146580

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

Upvotes: 3

Related Questions