6

I am new to Docker. I am using spring boot and when we build the project using maven, it will create jar file like app-.jar and then I am coping this jar file using ADD command in DockerFile. Now If I change the version number in pom.xml, then I need to manually update the JAR file name in DockerFile. Is there anyway by which I can dynamically get the version number which is in the pom.xml and update the JAR file name automatically in the DockerFile?

ninja.bhaSiv
  • 95
  • 2
  • 7

1 Answers1

0

Instead of copying the jar file inside the dockerfile, you can mount the folder in which jar is created. And you will not be needed to be worried with the filename.

What you want can be done using environment variables. You can create an --env-file and keep your version number there. And inside dockerfile, refer to value of variable declared in env file with {VERSIION}. By following this process, you may want to use this same version in your pom file. For that, take a look at this question.

The answer links environment variables by setting env.path and detailed guide is here.

Ayushya
  • 9,599
  • 6
  • 41
  • 57