Skip to content

Commit e342433

Browse files
Anil AllewarAnil Allewar
authored andcommitted
1. Got the docker compose to work; now we can build docker images for all projects and start them.\n 2. However the application still has issues running on docker
1 parent 66a614a commit e342433

File tree

32 files changed

+202
-50
lines changed

32 files changed

+202
-50
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ The application consists of 7 different services
3131
* [api-gateway](api-gateway/README.md) - API gateway that proxies all the micro-services
3232
* [web-portal](web-portal/README.md) - Single Page Application that provides the UI
3333

34+
You can build all the projects by running the `./build-all-projects.sh` on Mac/Linux systems and then going to each individual folder and running the jars using the `java -jar build/libs/sam<application_name>` command.
35+
3436
Please refer to the individual readme files on instructions of how to run the services. For demo, you can run the applications in the same order listed above.
3537

3638
Note:

api-gateway/bootstrap.yml

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

api-gateway/build.gradle

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ buildscript {
1515
}
1616
}
1717

18-
apply plugin: 'application'
1918
apply plugin: 'eclipse'
2019
apply plugin: 'spring-boot'
2120
apply plugin: 'java'
2221
apply plugin: 'docker'
2322

24-
2523
jar {
2624
baseName = 'sample-api-gateway'
2725
version = '0.0.1'
@@ -48,14 +46,44 @@ dependencies {
4846
testCompile 'org.springframework:spring-test:4.0.6.RELEASE'
4947
}
5048

51-
group = 'rohitghatol'
49+
/**
50+
* These values(group & mainClassName) are required by the gradle docker plugin.
51+
*
52+
* The "group" value feeds into the docker tag and is required if you want to push the images
53+
* to docker hub.
54+
*
55+
* The "mainClassName" value tells which class has the "main" entry point for running the
56+
* Spring boot application.
57+
*/
58+
group = 'anilallewar'
59+
mainClassName = 'com.rohitghatol.microservice.gateway.Application'
5260

5361
sourceCompatibility = 1.7
5462
targetCompatibility = 1.7
5563

56-
5764
distDocker {
5865
exposePort 8080
66+
setEnvironment 'JAVA_OPTS', '-Dspring.profiles.active=docker'
67+
}
68+
69+
/**
70+
* On Mac, docker can't be connected locally since it is running in a separate VM.
71+
*
72+
* NOTE: If you have not added your TLS certs to boot2docker; you would need to change
73+
* docker to run the API on HTTP; while boot2docker 1.3 comes with TLS enabled. Hence
74+
* you need to run the following command "$(docker run sequenceiq/socat)" at the docker
75+
* prompt so that this image maps the api to HTTP port. You can check that it is working
76+
* correctly using the command "curl http://192.168.59.103:2375/_ping"
77+
*
78+
*
79+
* In order to change docker to run the remote API, we need to set the following flags:
80+
* 1. useApi true => Use the Docker Remote API instead of a locally installed docker binary.
81+
* 2. hostUrl => set the URL used to contact the Docker server. Defaults to http://localhost:2375
82+
*/
83+
docker {
84+
useApi true
85+
hostUrl 'http://192.168.59.103:2375'
86+
baseImage = 'java:7'
5987
}
6088

6189
bootRun {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
spring:
2+
application:
3+
name: api-gateway
4+
cloud:
5+
config:
6+
uri: ${vcap.services.${PREFIX:}configserver.credentials.uri:http://localhost:8888}

auth-server/bootstrap.yml

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

auth-server/build.gradle

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ buildscript {
1515
}
1616
}
1717

18-
apply plugin: 'application'
1918
apply plugin: 'eclipse'
2019
apply plugin: 'spring-boot'
2120
apply plugin: 'java'
@@ -48,14 +47,22 @@ dependencies {
4847
testCompile 'org.springframework:spring-test:4.0.6.RELEASE'
4948
}
5049

51-
group = 'rohitghatol'
50+
group = 'anilallewar'
51+
mainClassName = 'com.rohitghatol.microservice.auth.Application'
5252

5353
sourceCompatibility = 1.7
5454
targetCompatibility = 1.7
5555

5656

5757
distDocker {
58-
exposePort 8080
58+
exposePort 8899
59+
setEnvironment 'JAVA_OPTS', '-Dspring.profiles.active=docker'
60+
}
61+
62+
docker {
63+
useApi true
64+
hostUrl 'http://192.168.59.103:2375'
65+
baseImage = 'java:7'
5966
}
6067

6168
bootRun {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
spring:
2+
application:
3+
name: auth-server
4+
cloud:
5+
config:
6+
uri: ${vcap.services.${PREFIX:}configserver.credentials.uri:http://localhost:8888}

build-all-projects.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
cd api-gateway; ./gradlew clean build; cd ..
4+
cd auth-server; ./gradlew clean build; cd ..
5+
cd config-server; ./gradlew clean build; cd ..
6+
cd task-webservice; ./gradlew clean build; cd ..
7+
cd user-webservice; ./gradlew clean build; cd ..
8+
cd web-portal; ./gradlew clean build; cd ..
9+
cd webservice-registry; ./gradlew clean build; cd ..
10+
cd comments-webservice; ./gradlew clean build; cd ..

0 commit comments

Comments
 (0)