leśnik leśnik - 1 year ago 127
Java Question

InteliJ Idea: build and run Java apps in docker containers

In my project I'd like to containerize my Spring Boot applications not only on production environment but also locally. In order to do that I'd like to:

  1. Start docker container (from a java image)

  2. Click "run" in IntelliJ Idea

  3. Build the application in the container (not using my local machine compiler but the one that is in the container)

  4. Run the application in the container

Is such scenario possible? I do not want to use Gradle or Maven to build the application in the container - I want to tell IntelliJ Idea to use the inside docker container java compiler, not the one that i have locally.

Answer Source

What might be helpful is described here. Basically you need devtools and run a spring-boot application inside a docker container - musn't be done via java -jar ... - rather with maven or gradle plugins. Then setup a java application configuration with RemoteSpringApplication class and it should work.

Unfortunately I've experienced some problems, see this question.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download