Skip to content

Commit 695ebbc

Browse files
committed
Added aws configuration and deploy
1 parent b0902a1 commit 695ebbc

4 files changed

Lines changed: 67 additions & 49 deletions

File tree

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Bootstrap project to work with microservices using Java
22

3-
Read the post talking about this [project](https://medium.com/hands-on-microservices-with-java/hands-on-microservices-with-java-e8a5b5b022ee)
3+
what the videos demonstrating the project
4+
5+
<a href="https://medium.com/@alexsandrosouza/bootstrapping-a-microservices-screencast-7212aa3912cc" target="_blank"><img src="http://img.youtube.com/vi/6LPDbgf5ssU/0.jpg"
6+
alt="Bootstrapping a microservice architecture" width="240" height="180" border="10" /></a>
47

58
The idea of this project is provide you a bootstrap for your next microservice architecture using Java.
69
On this repository we will be addressing some challenges that everyone faces when are starting with microservices.
@@ -26,9 +29,9 @@ CQRS, REST, Web Sockets, Continuous deploy with Jenkins, and all developed using
2629

2730
## How to use
2831

29-
* run package-projects.sh
30-
* run docker-orchestrate.sh
31-
* docker-compose -p todo up
32+
* run `package-projects.sh`
33+
* run `docker-orchestrate.sh`
34+
* `docker-compose -p todo up`
3235

3336
## Continuous deploy using Jenkins Pipeline
3437
We have created a docker image in order to have continuous deploy in our project [here](https://github.com/apssouza22/build-deploy).
@@ -42,6 +45,14 @@ and paste the content of the Jenkinsfile in the Pipeline script box. Have a look
4245
[video](https://www.youtube.com/watch?v=u3xLXEnlu2M&t=1023s&index=2&list=PLoO1q0-ZB3v6ZN6qvk0dsRRuxjiAQDuZx)
4346
to check how to work with Jenkins pipeline
4447

48+
### Deploy on AWS
49+
* Create your credentials on AWS
50+
* Create your cluster on AWS console
51+
* Have the build-deploy container running (Checkout in the project's README how to do it)
52+
* Access Jenkins painal
53+
* Create a pipeline job
54+
* Run the Job
55+
4556
### Accessing the services
4657
* Authenticate -> ```curl -X POST -vu todo-app:123456 http://localhost:8017/oauth/token -H "Accept: application/json" -d "password=1234&username=apssouza22@gmail.com&grant_type=password&scope=write&client_secret=123456&client_id=todo-app"```
4758

aws-compose.yml

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@ services:
1111
mem_limit: 1025288000
1212
cpu_shares: 100
1313
extra_hosts:
14-
- "eureka:52.16.120.13"
14+
- "eureka:EC2_INSTANCE_IP"
1515
environment:
1616
- JAVA_OPTS=' -Xmx800m'
1717

18-
1918
user:
2019
image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:user-service
2120
ports:
2221
- 8016:8016
23-
networks:
24-
- net
2522
hostname: user
2623
container_name: user
2724
command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
@@ -31,8 +28,8 @@ services:
3128
mem_limit: 1025288000
3229
cpu_shares: 100
3330
extra_hosts:
34-
- "config:52.16.120.13"
35-
- "eureka:52.16.120.13"
31+
- "config:EC2_INSTANCE_IP"
32+
- "eureka:EC2_INSTANCE_IP"
3633
environment:
3734
- JAVA_OPTS=' -Xmx800m'
3835

@@ -46,59 +43,51 @@ services:
4643
hostname: eureka
4744
container_name: eureka
4845
command: ["./wait-for-it.sh","config:8888","--timeout=100","--","/usr/local/bin/start.sh"]
49-
external_links:
50-
- elk
5146
mem_limit: 1025288000
5247
cpu_shares: 100
5348
extra_hosts:
54-
- "config:52.16.120.13"
49+
- "config:EC2_INSTANCE_IP"
5550
environment:
5651
- JAVA_OPTS=' -Xmx800m'
5752

58-
59-
mail:
60-
image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:mail-service
53+
oauth:
54+
image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:oauth-server
6155
ports:
62-
- 8020:8020
63-
networks:
64-
- net
65-
hostname: mail
66-
container_name: mail
67-
command: ["./wait-for-it.sh","config:8010","--timeout=150","--","/usr/local/bin/start.sh"]
56+
- 8017:8017
57+
hostname: oauth
58+
container_name: oauth
59+
command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
60+
mem_limit: 1025288000
61+
cpu_shares: 100
6862
extra_hosts:
69-
- "config:52.16.120.13"
70-
- "eureka:52.16.120.13"
71-
- "kafka:52.16.120.13"
72-
- "zookeeper:52.16.120.13"
63+
- "config:EC2_INSTANCE_IP"
64+
- "eureka:EC2_INSTANCE_IP"
7365
environment:
7466
- JAVA_OPTS=' -Xmx800m'
75-
mem_limit: 1025288000
76-
cpu_shares: 100
7767

78-
reminder:
79-
image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:reminder-service
68+
admin:
69+
image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:admin-server
70+
container_name: admin
8071
ports:
81-
- 8015:8015
82-
networks:
83-
- net
84-
hostname: reminder
85-
command: ["./wait-for-it.sh","config:8010","--timeout=150","--","/usr/local/bin/start.sh"]
86-
extra_hosts:
87-
- "config:52.16.120.13"
88-
- "eureka:52.16.120.13"
89-
- "kafka:52.16.120.13"
90-
- "zookeeper:52.16.120.13"
72+
- 8026:8026
9173
environment:
74+
- EUREKA_SERVICE_URL=http://EC2_INSTANCE_IP:8010
75+
- EUREKA_INSTANCE_PREFER_IP_ADDRESS=true
76+
- LOGGING_FILE=/tmp/admin.log
9277
- JAVA_OPTS=' -Xmx800m'
93-
mem_limit: 1025288000
78+
command: ["./wait-for-it.sh","EC2_INSTANCE_IP:8010","--timeout=150","--","/usr/local/bin/start.sh"]
79+
mem_limit: 1225288000
9480
cpu_shares: 100
81+
extra_hosts:
82+
- "config:EC2_INSTANCE_IP"
83+
- "eureka:EC2_INSTANCE_IP"
84+
environment:
85+
- JAVA_OPTS=' -Xmx800m'
9586

9687
zookeeper:
9788
image: wurstmeister/zookeeper
9889
ports:
9990
- 2181:2181
100-
networks:
101-
- net
10291
mem_limit: 925288000
10392
cpu_shares: 100
10493

@@ -107,7 +96,7 @@ services:
10796
ports:
10897
- 9092:9092
10998
environment:
110-
KAFKA_ZOOKEEPER_CONNECT: "52.16.120.13:2181"
99+
KAFKA_ZOOKEEPER_CONNECT: "EC2_INSTANCE_IP:2181"
111100
KAFKA_CREATE_TOPICS: "todo-mail:1:1"
112101
HOSTNAME_COMMAND: curl http://169.254.169.254/latest/meta-data/public-hostname
113102
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
@@ -118,9 +107,25 @@ services:
118107
- /var/run/docker.sock:/var/run/docker.sock
119108
hostname: kafka
120109
container_name: kafka
121-
networks:
122-
- net
123110
mem_limit: 1325288000
124111
cpu_shares: 100
125112
extra_hosts:
126-
- "zookeeper:52.16.120.13"
113+
- "zookeeper:EC2_INSTANCE_IP"
114+
115+
reminder:
116+
image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:reminder-service
117+
ports:
118+
- 8015:8015
119+
networks:
120+
- net
121+
hostname: reminder
122+
command: ["./wait-for-it.sh","config:8010","--timeout=150","--","/usr/local/bin/start.sh"]
123+
extra_hosts:
124+
- "config:52.50.116.215"
125+
- "eureka:52.50.116.215"
126+
- "kafka:52.50.116.215"
127+
- "zookeeper:52.50.116.215"
128+
environment:
129+
- JAVA_OPTS=' -Xmx800m'
130+
mem_limit: 1025288000
131+
cpu_shares: 100

aws-deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -ex
33

44
loginString="$(aws ecr get-login)"
55
${loginString/-e none/ }
6-
REPOSITORY_URI=004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex
6+
REPOSITORY_URI=${REPOSITORY_URI}
77

88
docker tag todo/oauth-server:latest ${REPOSITORY_URI}:oauth-server
99
docker push ${REPOSITORY_URI}:oauth-server

config-server/src/main/resources/offline-repository/eureka-server.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ spring:
88

99
server:
1010
port: 8010
11-
11+
1212
eureka:
1313
instance:
1414
hostname: localhost
15+
preferIpAddress: true
16+
# ipAddress: 52.50.116.215
1517
client:
1618
registerWithEureka: false
1719
fetchRegistry: false

0 commit comments

Comments
 (0)