PetClinic Monolith Workshop
Building the Spring PetClinic Application
The first thing we need to set up APM is… well, an application. For this exercise, we will use the Spring PetClinic application. This is a very popular sample Java application built with the Spring framework (via Spring Boot).
First, clone the Spring PetClinic GitHub repository. Later, we will compile, build, package and test the application:
git clone https://github.com/spring-projects/spring-petclinicChange into the spring-petclinic directory:
cd spring-petclinic
git checkout b26f235250627a235a2974a22f2317dbef27338dUsing Docker, start a MySQL database for PetClinic to use:
docker run -d -e MYSQL_USER=petclinic -e MYSQL_PASSWORD=petclinic -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=petclinic -p 3306:3306 docker.io/biarms/mysql:5.7Next, we will start another container running Locust that will generate some traffic in the Spring PetClinic application. Locust is a simple load-testing tool.
docker run --network="host" -d -p 8090:8090 -v ~/workshop/petclinic:/mnt/locust docker.io/locustio/locust -f /mnt/locust/locustfile.py --headless -u 1 -r 1 -H http://127.0.0.1:8083Next, compile, build and package the application using maven:
./mvnw package -Dmaven.test.skip=trueNote
This command will take a few minutes to complete the first time, because it downloads a lot of dependencies before compiling the application. Future builds will be much quicker.
Once the build completes, you need to obtain the public IP address of the instance you are running on. You can do this by running the following command:
curl http://ifconfig.meMake a note of the IP address returned by this command, as we will need it to validate that the application is running.
