Skip to content

Java Spring Boot Demo application illustrating external configuration using different methods in a Docker deployment

Notifications You must be signed in to change notification settings

Allaman/spring-demo

Repository files navigation

Java Spring Boot Demo Application

This is an rather minimalism Java Spring Boot Demo application illustrating external configuration using different methods in a Docker deployment (see Showcased for more information).

Additionally, you can spin up a minimal monitoring setup with preconfigured Prometheus and Grafana services including metrics from the JVM, your hosts and your docker container. The stack itself is deployed as docker container so there is no pollution of your system.

There is also a branch for the spring-boot 1.4 release (not fully equivalent)

Requirements

  • Docker
  • Docker-compose
  • default port 8080 for the application
  • port 3000 and 9090 for Grafana and Prometheus
  • port 9100 and 9200 for NodeExporter and cAdvisor

If you want to build the application without Docker:

  • Java JDK >1.8
  • Maven

Build the build Docker image

Clone or download this repository and cd into this folder.

docker build -f Dockerfile.build -t spring-builder .

Build the application inside the build container

docker run --rm --name spring-builder -v /var/run/docker.sock:/var/run/docker.sock spring-builder

Start demo application and Prometheus stack

sh start.sh

Stop demo application and Prometheus stack

sh stop.sh

Accessing the demo application

  • Application output of different external configuration options: curl localhost:8080
  • Actuator security is disabled: curl http://localhost:8080/env
  • All actuators are exposed and accessible: curl http://localhost:8080/actuator/

External configuration showcased

  1. System environment variables from .env file
  2. System environment variables from docker-compose file
  3. Config variables from a YAML file
  4. Config variable from a application properties file including nesting and arrays
  5. Environment-based spring profile configuration

Monitoring

Dashboard

Dashboard2

Access Grafana (admin:admin) and Prometheus and find a configured data source as well as dashboards for showing Prometheus itself and a basic java Micrometer dashboard.

Official Documentation

About

Java Spring Boot Demo application illustrating external configuration using different methods in a Docker deployment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published