- Linux, VirtualBox or Docker Desktop
- Java 11
- Maven
- Git Config Server Repository
- Spring Boot : 2.5.0
- Netflix Eureka Client
- Google Container Tools
- H2 Database
- Lombok
- Zipkin
src/main/docker/app.yml
version: '3.8'
services:
task-service:
image: cevheri/task-service
environment:
- _JAVA_OPTIONS=-Xmx512m -Xms256m
- APP_SLEEP=10 # for zipkin
ports:
- 9003:9003
zipkin:
image: openzipkin/zipkin
ports:
- 9411:9411
We will use github public repository for our configuration: https://github.com/cevheri/microservices-config-server
$ ./mvnw package
$ java -jar target/*.jar
Visit : http://localhost:8761/eureka/apps/task-service
We will create Docker Image using Google Container Tools and run this Docker Image with Docker Compose.
$ ./mvnw -Pprod clean verify jib:dockerBuild
...
[INFO] Executing tasks:
[INFO] [==============================] 100.0% complete
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.728 s
[INFO] Finished at: 21:45:11+03:00
[INFO] ------------------------------------------------------------------------
$ docker-compose -f src/main/docker/app.yml up -d
Creating task-service ... done
Visit : http://localhost:8761/eureka/apps/task-service
<application>
<name>TASK-SERVICE</name>
<instance>
<instanceId>192.168.1.57:task-service:9003</instanceId>
<hostName>service-registry</hostName>
<app>TASK-SERVICE</app>
<ipAddr>192.168.1.57</ipAddr>
<status>UP</status>
...
...
</instance>
</application>
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
cevheri/task-service latest 57a100df8bcd 26 minutes ago 287MB
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2ca74578a26c cevheri/task-service "bash -c /entrypoint…" 8 seconds ago Up 6 seconds 0.0.0.0:9003->9003/tcp, :::9003->9003/tcp task-service
$ docker-compose -f src/main/docker/app.yml down