Skip to content

Commit 839f377

Browse files
committed
docker-compose fix added
1 parent 8853c68 commit 839f377

File tree

23 files changed

+431
-157
lines changed

23 files changed

+431
-157
lines changed

api-gateway-service/.gitignore

Lines changed: 0 additions & 24 deletions
This file was deleted.

api-gateway-service/src/main/java/com/lohika/jclub/ApiGatewayServiceApplication.java renamed to api-gateway-service/src/main/java/com/lohika/jclub/gateway/ApiGatewayServiceApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.lohika.jclub;
1+
package com.lohika.jclub.gateway;
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;

api-gateway-service/src/main/resources/application.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ server.port=8090
33

44
eureka.instance.preferIpAddress=true
55

6+
feign.hystrix.enabled=true
7+
68
management.security.enabled=false
79

810
endpoints.info.id=info

api-gateway-service/src/test/java/com/lohika/jclub/ApiGatewayServiceApplicationTests.java renamed to api-gateway-service/src/test/java/com/lohika/jclub/gateway/ApiGatewayServiceApplicationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.lohika.jclub;
1+
package com.lohika.jclub.gateway;
22

33
import org.junit.Test;
44
import org.junit.runner.RunWith;
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
FROM java:8
2+
3+
RUN mkdir -p /opt/spring-cloud
4+
WORKDIR /opt/spring-cloud
5+
26
ADD client-service.jar client-service.jar
37
ADD wrapper.sh wrapper.sh
4-
RUN bash -c 'chmod +x /wrapper.sh'
5-
RUN bash -c 'touch /client-service.jar'
8+
9+
RUN bash -c 'chmod +x ./wrapper.sh'
10+
RUN bash -c 'touch ./client-service.jar'
11+
612
ENTRYPOINT ["/bin/bash", "./wrapper.sh"]

client-service/src/main/java/com/lohika/jclub/client/ClientServiceApplication.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package com.lohika.jclub.client;
22

33
import com.lohika.jclub.storage.client.EnableStorageServiceClient;
4+
import com.lohika.jclub.storage.client.StorageServiceClient;
45

56
import org.springframework.boot.SpringApplication;
67
import org.springframework.boot.autoconfigure.SpringBootApplication;
7-
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
8-
import org.springframework.context.annotation.Bean;
9-
import org.springframework.web.client.RestTemplate;
8+
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
9+
import org.springframework.cloud.netflix.feign.EnableFeignClients;
1010

11-
@SpringBootApplication
11+
@EnableDiscoveryClient
1212
@EnableStorageServiceClient
13+
@EnableFeignClients(clients = {StorageServiceClient.class})
14+
@SpringBootApplication
1315
public class ClientServiceApplication {
1416

1517
public static void main(String[] args) {
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
FROM java:8
2+
3+
RUN mkdir -p /opt/spring-cloud
4+
WORKDIR /opt/spring-cloud
5+
26
ADD config-server.jar config-server.jar
37
ADD wrapper.sh wrapper.sh
4-
RUN bash -c 'chmod +x /wrapper.sh'
5-
RUN bash -c 'touch /config-server.jar'
6-
ENTRYPOINT ["/bin/bash", "/wrapper.sh"]
8+
9+
RUN bash -c 'chmod +x ./wrapper.sh'
10+
RUN bash -c 'touch ./config-server.jar'
11+
12+
ENTRYPOINT ["/bin/bash", "./wrapper.sh"]

dsl-executor-service/pom.xml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2424
<java.version>1.8</java.version>
2525
<spring-cloud.version>Dalston.RELEASE</spring-cloud.version>
26+
<docker.baseDir>${basedir}/src/main/docker</docker.baseDir>
2627
</properties>
2728

2829
<dependencies>
@@ -74,4 +75,54 @@
7475
</dependencies>
7576
</dependencyManagement>
7677

78+
<build>
79+
<plugins>
80+
<plugin>
81+
<groupId>org.springframework.boot</groupId>
82+
<artifactId>spring-boot-maven-plugin</artifactId>
83+
</plugin>
84+
<plugin>
85+
<artifactId>maven-antrun-plugin</artifactId>
86+
<configuration>
87+
<tasks>
88+
<copy file="${project.build.directory}/${project.build.finalName}.jar"
89+
tofile="${project.build.directory}/${project.artifactId}.jar"/>
90+
</tasks>
91+
</configuration>
92+
<executions>
93+
<execution>
94+
<phase>install</phase>
95+
<goals>
96+
<goal>run</goal>
97+
</goals>
98+
</execution>
99+
</executions>
100+
</plugin>
101+
<plugin>
102+
<groupId>com.spotify</groupId>
103+
<artifactId>docker-maven-plugin</artifactId>
104+
<version>1.0.0</version>
105+
<executions>
106+
<execution>
107+
<id>build-image</id>
108+
<phase>install</phase>
109+
<goals>
110+
<goal>build</goal>
111+
</goals>
112+
</execution>
113+
</executions>
114+
<configuration>
115+
<imageName>${project.artifactId}</imageName>
116+
<dockerDirectory>${docker.baseDir}</dockerDirectory>
117+
<resources>
118+
<resource>
119+
<targetPath>/</targetPath>
120+
<directory>${project.build.directory}</directory>
121+
<include>${project.artifactId}.jar</include>
122+
</resource>
123+
</resources>
124+
</configuration>
125+
</plugin>
126+
</plugins>
127+
</build>
77128
</project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM java:8
2+
3+
RUN mkdir -p /opt/spring-cloud
4+
WORKDIR /opt/spring-cloud
5+
6+
ADD dsl-executor-service.jar dsl-executor-service.jar
7+
ADD wrapper.sh wrapper.sh
8+
9+
RUN bash -c 'chmod +x ./wrapper.sh'
10+
RUN bash -c 'touch ./dsl-executor-service.jar'
11+
12+
ENTRYPOINT ["/bin/bash", "./wrapper.sh"]
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
WAITING_FOR_DEPENDENCE=${WAITING_FOR_DEPENDENCE:='false'}
4+
5+
if [ "$WAITING_FOR_DEPENDENCE" != "true" ]; then
6+
echo "Starting dsl-executor server immediately"
7+
java -jar ./dsl-executor-service.jar
8+
exit 0
9+
fi
10+
11+
DISCOVERY_SERVER_HOST=${DISCOVERY_SERVER_HOST:='discovery-server'}
12+
DISCOVERY_SERVER_PORT=${DISCOVERY_SERVER_PORT:=8761}
13+
14+
echo "Trying to connect to discovery server on ${DISCOVERY_SERVER_HOST}:${DISCOVERY_SERVER_PORT}"
15+
until $(curl --output /dev/null --silent --head --fail "http://${DISCOVERY_SERVER_HOST}:${DISCOVERY_SERVER_PORT}/info"); do
16+
echo -e ".\c"
17+
sleep 1
18+
done
19+
echo
20+
21+
STORAGE_SERVICE=${STORAGE_SERVICE:='storage-service'}
22+
echo "Trying to get '${STORAGE_SERVICE}' from ${DISCOVERY_SERVER_HOST}:${DISCOVERY_SERVER_PORT}"
23+
until $(curl --output /dev/null --silent --head --fail "http://${DISCOVERY_SERVER_HOST}:${DISCOVERY_SERVER_PORT}/eureka/apps/${STORAGE_SERVICE}"); do
24+
echo -e ".\c"
25+
sleep 1
26+
done
27+
echo
28+
29+
RATING_SERVICE=${RATING_SERVICE:='rating-service'}
30+
echo "Trying to get '${RATING_SERVICE}' from ${DISCOVERY_SERVER_HOST}:${DISCOVERY_SERVER_PORT}"
31+
until $(curl --output /dev/null --silent --head --fail "http://${DISCOVERY_SERVER_HOST}:${DISCOVERY_SERVER_PORT}/eureka/apps/${RATING_SERVICE}"); do
32+
echo -e ".\c"
33+
sleep 1
34+
done
35+
echo
36+
37+
HACKSTER_SERVICE=${HACKSTER_SERVICE:='hackster-service'}
38+
echo "Trying to get '${HACKSTER_SERVICE}' from ${DISCOVERY_SERVER_HOST}:${DISCOVERY_SERVER_PORT}"
39+
until $(curl --output /dev/null --silent --head --fail "http://${DISCOVERY_SERVER_HOST}:${DISCOVERY_SERVER_PORT}/eureka/apps/${HACKSTER_SERVICE}"); do
40+
echo -e ".\c"
41+
sleep 1
42+
done
43+
echo
44+
45+
echo "Starting dsl-executor server"
46+
echo "Setting eureka.client.serviceUrl.defaultZone to http://${DISCOVERY_SERVER_HOST}:${DISCOVERY_SERVER_PORT}/eureka"
47+
48+
env "eureka.client.serviceUrl.defaultZone=http://${DISCOVERY_SERVER_HOST}:${DISCOVERY_SERVER_PORT}/eureka" \
49+
java -jar ./dsl-executor-service.jar

0 commit comments

Comments
 (0)