The Spring Music application was designed to work with a number of data stores, including MySQL, Postgres, Oracle, MongoDB, Redis, and H2, an in-memory Java SQL database. NGINX redirects requests, which are not for non-static assets, to one of the three Tomcat instances on port 8080. Reverse proxying and caching are configured thought NGINX’s nf file, in the server configuration section:Ĭlient requests are received through port 80 on the NGINX server. In many enterprise environments, the use of a Java EE application server, like Tomcat, is still not uncommon. To further increase application performance, NGINX will also be configured for browser caching of the static content. Requests for non-static content will be proxied through NGINX on the front-end, to a set of three load-balanced Tomcat instances on the back-end. The application’s WAR file will be hosted by Apache Tomcat 8.5.4. To increase performance, the Spring Music web application’s static content will be hosted by NGINX. We will use the following technologies to build, publish, deploy, and host the Java Spring Music application: Gradle, git, GitHub, Travis CI, Oracle VirtualBox, Docker, Docker Compose, Docker Machine, Docker Hub, and optionally, Amazon Web Services (AWS).
Update versions of several dependencies, including Gradle, Spring, and Tomcat.
Add Gradle zipStatic task to ZIP up the application’s static assets for deployment to NGINX.Add Gradle warNoStatic task to build WAR without static assets.Modify MongoDB configuration class to work with non-local, containerized MongoDB instances.Add unit tests for Continuous Integration demonstration purposes.Move from Java 1.7 to 1.8 (including newer Tomcat version).Testing frameworks include the Spring MVC Test Framework, Mockito, Hamcrest, and JUnit.Ī few changes were made to the original Spring Music application to make it work for this demonstration, including: The Java Spring Music application stack contains the following technologies: Java, Spring Framework, AngularJS, Bootstrap, jQuery, NGINX, Apache Tomcat, MongoDB, the ELK Stack, and Filebeat.
The Spring Music source code is stored on the springmusic_v2 branch of the garystafford/spring-music repository, also on GitHub. Instead of Cloud Foundry, we will host the Spring Music application locally, using Docker on VirtualBox, and optionally on AWS.Īll files necessary to build this project are stored on the docker_v2 branch of the garystafford/spring-music-docker repository on GitHub. The Spring Music sample record album collection application was originally designed to demonstrate the use of database services on Cloud Foundry, using the Spring Framework. We will use a sample Java Spring application, Spring Music, available on GitHub from Cloud Foundry.
In this post, we will demonstrate how to build, test, deploy, and manage a Java Spring web application, hosted on Apache Tomcat, load-balanced by NGINX, monitored by ELK with Filebeat, and all containerized with Docker. The post’s project was also updated to use Filebeat with ELK, as opposed to Logspout, which was used previously.
This new post incorporates many improvements made in Docker 1.12, including the use of the new Docker Compose v2 YAML format. This post and the post’s example project represent an update to a previous post, Build and Deploy a Java-Spring-MongoDB Application using Docker.