Set up your Java development environment with Docker

The last couple of days I spend a lot of time digging into the docker. I am really impressed with the opportunity to have a development environment that can be the same as in production!

At the moment, I want to start small and begin to improve the development process. We are developing Java applications that are deployed to tomcat. Developers use IDEs such as Eclipse and IntelliJ.

During development, you configure the tomcat environment in the IDE so that you can automatically deploy and debug your code. Therefore, the tomcat base directory must be accessible for configuration.

I currently have a deber debian image with tomcat installed on / opt / tomcat.

Now I was hoping to associate the contents of the container / opt / tomcat directory with the directory on my host. Unfortunately, this feature does not seem to exist. With the -v option, you can only mount the host directory in the container, and not vice versa.

Currently, the only solution that I see will be to build the container webapps directory and drop my war file here, which, in my opinion, is quite unproductive.

You need to start / restart tomcat manually, only remote debugging is possible, you do not have your logs in the IDE console.

So, are there any ideas on optimizing Java Webapp development workflow using docker?

+6
source share
3 answers

I saw a blog that talked about doclipser (Eclipse + Docker).

On the blog, mainly at the bottom of the post, he mentioned the following tools:

Hope this helps :)

+2
source

You may need to run Eclipse and Tomcat in the same container, however I would definitely try to run them in two separate containers. Perhaps start with this basic image and try associating it with a Tomcat image using a shared volume.

+1
source

If I understand your problem correctly, why not just use the -v to mount the war file itself. This worked for me using wildfly.

Basically, I use maven to build a war and map target/myapp.war to /opt/wildfly/myapp.war . Then, when I make changes to the application, I simply run mvn clean package and the application container, seeing that the war has changed, redistributes.

Now it uses the wildfly deployment scanner, but it can work for tomcat as well. If not, maybe you can run tomcat with a war exploded, and then just set the build folder, target / myapp, to the webapps folder on tomcat.

-1
source

Source: https://habr.com/ru/post/980632/


All Articles