Skip to content

Commit 9c9beb2

Browse files
committed
Added Docker Compose for Hystrix Dashboard. We generated docker image by "Google Container Tools". We used github repository for our configuration by config-server.
1 parent cb34778 commit 9c9beb2

File tree

5 files changed

+171
-24
lines changed

5 files changed

+171
-24
lines changed

hystrix-dashboard/.gitignore

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,13 @@
1-
HELP.md
1+
22
target/
3+
.vscode/
4+
35
!.mvn/wrapper/maven-wrapper.jar
46
!**/src/main/**/target/
57
!**/src/test/**/target/
68

7-
### STS ###
8-
.apt_generated
9-
.classpath
10-
.factorypath
11-
.project
12-
.settings
13-
.springBeans
14-
.sts4-cache
15-
169
### IntelliJ IDEA ###
17-
.idea
10+
.idea/
1811
*.iws
1912
*.iml
2013
*.ipr
21-
22-
### NetBeans ###
23-
/nbproject/private/
24-
/nbbuild/
25-
/dist/
26-
/nbdist/
27-
/.nb-gradle/
28-
build/
29-
!**/src/main/**/build/
30-
!**/src/test/**/build/
31-
32-
### VS Code ###
33-
.vscode/

hystrix-dashboard/README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Java Microservices - Hystrix Dashboard
2+
3+
4+
## Dependencies
5+
* Linux, VirtualBox or Docker Desktop
6+
* Java 11
7+
* Maven
8+
* Git Config Server Repository
9+
* Spring Boot : 2.3.11.RELEASE
10+
* new version spring, is not supported
11+
* Hystrix Dashboard
12+
* Netflix Eureka Client
13+
* Google Container Tools
14+
* H2 Database
15+
* Lombok
16+
* Zipkin
17+
18+
## Configuration
19+
src/main/docker/app.yml
20+
```yaml
21+
version: '3.8'
22+
services:
23+
hystrix-dashboard:
24+
image: cevheri/hystrix-dashboard
25+
environment:
26+
- _JAVA_OPTIONS=-Xmx512m -Xms256m
27+
ports:
28+
- 9295:9295
29+
```
30+
31+
We will use github public repository for our configuration:
32+
https://github.com/cevheri/microservices-config-server
33+
34+
35+
---
36+
## Development
37+
```shell
38+
$ ./mvnw package
39+
$ java -jar target/*.jar
40+
```
41+
Visit : http://localhost:8761/eureka/apps/hystrix-dashboard
42+
43+
---
44+
## Production With Docker
45+
We will create Docker Image using Google Container Tools and run this Docker Image with Docker Compose.
46+
47+
### Build docker image:
48+
```shell
49+
$ ./mvnw -Pprod clean verify jib:dockerBuild
50+
51+
...
52+
[INFO] Executing tasks:
53+
[INFO] [==============================] 100.0% complete
54+
[INFO]
55+
[INFO] ------------------------------------------------------------------------
56+
[INFO] BUILD SUCCESS
57+
[INFO] ------------------------------------------------------------------------
58+
[INFO] Total time: 17.728 s
59+
[INFO] Finished at: 21:45:11+03:00
60+
[INFO] ------------------------------------------------------------------------
61+
```
62+
63+
---
64+
65+
### Run:
66+
```shell
67+
$ docker-compose -f src/main/docker/app.yml up -d
68+
69+
Creating hystrix-dashboard ... done
70+
```
71+
---
72+
Visit : http://localhost:8761/eureka/apps/hystrix-dashboard
73+
```xml
74+
<application>
75+
<name>hystrix-dashboard</name>
76+
<instance>
77+
<instanceId>192.168.1.57:hystrix-dashboard:9295</instanceId>
78+
<hostName>service-registry</hostName>
79+
<app>hystrix-dashboard</app>
80+
<ipAddr>192.168.1.57</ipAddr>
81+
<status>UP</status>
82+
...
83+
...
84+
</instance>
85+
</application>
86+
```
87+
88+
---
89+
### View docker images:
90+
```shell
91+
$ docker images
92+
93+
REPOSITORY TAG IMAGE ID CREATED SIZE
94+
cevheri/hystrix-dashboard latest 67a100df8bcx 26 minutes ago 120MB
95+
```
96+
97+
### View docker containers:
98+
````shell
99+
$ docker ps
100+
101+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
102+
6ca74578a26x cevheri/hystrix-dashboard "bash -c /entrypoint…" 8 seconds ago Up 6 seconds 0.0.0.0:9295->9295/tcp, :::9295->9295/tcp hystrix-dashboard
103+
````
104+
105+
### Stop Docker Compose:
106+
```shell
107+
$ docker-compose -f src/main/docker/app.yml down
108+
```

hystrix-dashboard/pom.xml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<properties>
1717
<java.version>11</java.version>
1818
<spring-cloud.version>Hoxton.SR11</spring-cloud.version>
19+
<jib-maven-plugin.version>2.8.0</jib-maven-plugin.version>
1920
</properties>
2021
<dependencies>
2122
<dependency>
@@ -72,7 +73,54 @@
7273
<groupId>org.springframework.boot</groupId>
7374
<artifactId>spring-boot-maven-plugin</artifactId>
7475
</plugin>
76+
<plugin>
77+
<groupId>com.google.cloud.tools</groupId>
78+
<artifactId>jib-maven-plugin</artifactId>
79+
</plugin>
7580
</plugins>
81+
82+
<pluginManagement>
83+
<plugins>
84+
<plugin>
85+
<groupId>com.google.cloud.tools</groupId>
86+
<artifactId>jib-maven-plugin</artifactId>
87+
<version>${jib-maven-plugin.version}</version>
88+
<configuration>
89+
<from>
90+
<image>adoptopenjdk:11-jre-hotspot</image>
91+
</from>
92+
<to>
93+
<image>cevheri/hystrix-dashboard:latest</image>
94+
</to>
95+
<container>
96+
<entrypoint>
97+
<shell>bash</shell>
98+
<option>-c</option>
99+
<arg>/entrypoint.sh</arg>
100+
</entrypoint>
101+
<ports>
102+
<port>9295</port>
103+
</ports>
104+
<environment>
105+
<SPRING_OUTPUT_ANSI_ENABLED>ALWAYS</SPRING_OUTPUT_ANSI_ENABLED>
106+
<APP_SLEEP>0</APP_SLEEP>
107+
</environment>
108+
<creationTime>USE_CURRENT_TIMESTAMP</creationTime>
109+
<user>1000</user>
110+
</container>
111+
<extraDirectories>
112+
<paths>src/main/docker/jib</paths>
113+
<permissions>
114+
<permission>
115+
<file>/entrypoint.sh</file>
116+
<mode>755</mode>
117+
</permission>
118+
</permissions>
119+
</extraDirectories>
120+
</configuration>
121+
</plugin>
122+
</plugins>
123+
</pluginManagement>
76124
</build>
77125

78126
</project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: '3.8'
2+
services:
3+
hystrix-dashboard:
4+
image: cevheri/hystrix-dashboard
5+
environment:
6+
- _JAVA_OPTIONS=-Xmx512m -Xms256m
7+
ports:
8+
- 9295:9295
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
exec java ${JAVA_OPTS} -noverify -XX:+AlwaysPreTouch -Djava.security.egd=file:/dev/./urandom -cp /app/resources/:/app/classes/:/app/libs/* "com.cevher.ms.dashboard.HystrixDashboardApplication" "$@"

0 commit comments

Comments
 (0)