From 69219fa4274d3a7515a3ed04120e5a1a53ebe83f Mon Sep 17 00:00:00 2001 From: Simon Taylor Date: Mon, 21 Oct 2024 20:01:43 +0100 Subject: [PATCH] Added instructions to README for creating and testing a docker image for the service and resolved warnings that were displayed when running the tests --- README.md | 21 +++++++++++++++++++-- docker-compose.service.yml | 12 ++++++++++++ docker-compose.yml | 2 +- pom.xml | 22 ++++++++++++++++++++++ 4 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 docker-compose.service.yml diff --git a/README.md b/README.md index 4f35b1d..2b62ac7 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,8 @@ through the use of environment variables to point at a postgres database running ```shell $ SPRING_DATASOURCE_URL=jdbc:postgresql://127.0.0.1:59314/spt-recruitment-demo \ - SPRING_DATASOURCE_USERNAME=postgres SPRING_DATASOURCE_PASSWORD=p@ssw0rd \ + SPRING_DATASOURCE_USERNAME=postgres \ + SPRING_DATASOURCE_PASSWORD=p@ssw0rd \ SPRING_ACTIVEMQ_BROKER_URL=tcp://localhost:59313 \ java -jar target/spt-development-demo-0.0.1-SNAPSHOT.jar ``` @@ -86,4 +87,20 @@ $ curl -v -u bob:password123! http://localhost:8080/api/v1.0/books/4 ``` ```shell $ curl -v -u bob:password123! -X DELETE http://localhost:8080/api/v1.0/books/4 -``` \ No newline at end of file +``` +Running the demo in docker +========================== + +There are multiple ways to [build a docker image](https://www.baeldung.com/spring-boot-docker-images) for Spring Boot +applications. The simplest way is to use Buildpacks. + +```shell +$ ./mvnw spring-boot:build-image +``` +The [docker-compose.service.yml](./docker-compose.service.yml) can then be used to run the image along with +[docker-compose.yml](./docker-compose.yml) to start up Postgres and ActiveMQ. + +```shell +$ docker compose -f docker-compose.yml -f docker-compose.service.yml up -d +``` +The cURL commands above can again be used to test the API. \ No newline at end of file diff --git a/docker-compose.service.yml b/docker-compose.service.yml new file mode 100644 index 0000000..73f4c85 --- /dev/null +++ b/docker-compose.service.yml @@ -0,0 +1,12 @@ +version: '3.7' + +services: + api: + image: docker.io/library/spt-development-demo:0.0.1-SNAPSHOT + environment: + SPRING_DATASOURCE_URL: jdbc:postgresql://spt-development-demo-db-1:5432/spt-recruitment-demo + SPRING_DATASOURCE_USERNAME: postgres + SPRING_DATASOURCE_PASSWORD: p@ssw0rd + SPRING_ACTIVEMQ_BROKER_URL: tcp://spt-development-demo-activemq-1:61616 + ports: + - "8080:8080" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 2a39a54..954e7cf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: ports: - "5432" - artemis: + activemq: image: apache/activemq-classic:6.1.0 ports: - "61616" diff --git a/pom.xml b/pom.xml index 637d6ce..c527533 100644 --- a/pom.xml +++ b/pom.xml @@ -460,6 +460,17 @@ maven-failsafe-plugin + -XX:+EnableDynamicAgentLoading ${argLine} + + -XX:+EnableDynamicAgentLoading ${argLine} false **/*Test.java