1

Building a springboot application version 2.3. I want to build a docker image with the cloud native build packs. I have 2 springboot applications sitting inside my repository, say App A and App B. Usually, I do mvn install, pick up the jars and start them individually. Run jar "a" for aapp a and jar "b" for app b. Now, How do I tell the build pack on which jar I want to build my docker image on.

Rajesh
  • 153
  • 6
  • I don't understand your question. Simply start mvn spring-boot:build-image – Simon Martinelli Jul 16 '20 at 08:28
  • What tool are you using to run the build? `pack` or another platform like `kpack`? – Andrew M. Jul 16 '20 at 13:30
  • I would also like to raise the question why you have 2 runnable Spring Boot applications inside one repository. I'd like to shape my Git repositories according to the deployment later. If you deploy them separately (which I assume) it's maybe time to think about refactoring both into seperate repositories... And if there's code to share, you'd might end up having a 3rd repo for that, which produces a Maven module which is used by the others. – jonashackt Dec 04 '20 at 11:22

2 Answers2

2

Building on a stack of other answers, you can use the advanced reactor options to target a single module in the reactor and build the image just for that module.

A command like

mvn -pl <module-name> -am spring-boot:build-image

will likely give you what you're looking for.

Ben Hale
  • 567
  • 3
  • 7
0

Whichever platform you're using, you should be able to point the build toward your relevant subdirectory. For instance, if you're using pack, you can use pack build -p <repo dir>/<app A dir>. Depending on which Java buildpack you're using, it should run Maven for you and set up the resulting JAR to launch when the app image is started.

Andrew M.
  • 832
  • 1
  • 8
  • 18