This is a very simple micro service that can be built and packaged into a docker image. You should use this micro service as a template for building your own micro services.
-
Compile and package the application
$ mvn clean package -
Build the docker image
$ docker build -t template-microservice . -
Run the container
$ docker run -p 8080:8080 template-microservice -
Test the micro service
$ curl http://localhost:8080 Success! The Framework Training template microservices is up and running
To use this template you need to copy and then edit a few key files.
-
Make a new directory and copy the template
$ mkdir ../simpleservice $ cp -R * ../simpleservice/ $ cd ../simpleservice/ -
Edit pom.xml. Change the artifactId and name values
<artifactId>simpleservice</artifactId> <name>Simple Microservice</name> -
Edit Dockerfile and change the jar file name on the ADD instruction
ADD target/simpleservice-0.0.2-SNAPSHOT.jar app.jar -
Compile and package the application
$ mvn clean package -
Build the docker image
$ docker build -t simpleservice . -
Run the container
$ docker run -p 8080:8080 simpleservice -
Test the micro service
$ curl http://localhost:8080 Success! The Framework Training template microservices is up and running -
You can now import your new micro service project into your favourite IDE and start development