Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.

Commit f9b9881

Browse files
committed
last commit before M|17 Conference
1 parent f981265 commit f9b9881

File tree

8 files changed

+73
-60
lines changed

8 files changed

+73
-60
lines changed

docker-compose-registrator.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: '2'
2+
3+
services:
4+
registrator:
5+
image: gliderlabs/registrator:v7
6+
depends_on:
7+
- consul
8+
hostname: registrator
9+
volumes:
10+
- "/var/run/docker.sock:/tmp/docker.sock"
11+
command: -internal consul://consul:8500
12+
restart: always
13+
environment:
14+
- "affinity:com.mariadb.host!=registrator"
15+
labels:
16+
- "com.mariadb.host=registrator"
17+
consul:
18+
image: "progrium/consul:latest"
19+
hostname: "consul"
20+
ports:
21+
- "8400:8400"
22+
- "8500:8500"
23+
- "8600:53/udp"
24+
command: "-server -bootstrap -ui-dir /ui"
25+
restart: always
26+
vizualizer:
27+
image: bstaijen/mariadb-microservice-vizualizersvc:demo
28+
ports:
29+
- 3000:3000
30+
environment:
31+
- SWARM_HOST
32+
- SWARM_CA
33+
- SWARM_KEY
34+
- SWARM_CERT
35+
- "constraint:node==master"
36+
restart: always

docker-compose.yml

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ services:
2424
- "com.mariadb.host=webserver"
2525
authentication:
2626
image: bstaijen/mariadb-microservice-authenticationsvc:demo
27-
depends_on:
28-
- registrator
2927
ports:
3028
- "5001:5001"
3129
restart: always
@@ -42,8 +40,6 @@ services:
4240
- "com.mariadb.host=authenticationsvc"
4341
photo:
4442
image: bstaijen/mariadb-microservice-photosvc:demo
45-
depends_on:
46-
- registrator
4743
ports:
4844
- "5002:5002"
4945
restart: always
@@ -62,9 +58,7 @@ services:
6258
labels:
6359
- "com.mariadb.host=photosvc"
6460
vote:
65-
image: bstaijen/mariadb-microservice-votesvc:demo
66-
depends_on:
67-
- registrator
61+
image: bstaijen/mariadb-microservice-voteservice:demo
6862
ports:
6963
- "5003:5003"
7064
restart: always
@@ -81,9 +75,7 @@ services:
8175
labels:
8276
- "com.mariadb.host=votesvc"
8377
comment:
84-
image: bstaijen/mariadb-microservice-commentsvc:demo3
85-
depends_on:
86-
- registrator
78+
image: bstaijen/mariadb-microservice-commentsvc:demo
8779
ports:
8880
- "5004:5004"
8981
restart: always
@@ -103,8 +95,6 @@ services:
10395
- "com.mariadb.host=commentsvc"
10496
profile:
10597
image: bstaijen/mariadb-microservice-profilesvc:demo
106-
depends_on:
107-
- registrator
10898
ports:
10999
- "5000:5000"
110100
restart: always
@@ -121,8 +111,6 @@ services:
121111
- "com.mariadb.host=profilesvc"
122112
db:
123113
image: bstaijen/mariadb-microservice-database:demo
124-
depends_on:
125-
- registrator
126114
restart: always
127115
environment:
128116
- "MYSQL_ROOT_PASSWORD=password"
@@ -137,36 +125,4 @@ services:
137125
- 3306:3306
138126
- 4567-4568:4567-4568
139127
- 4444:4444
140-
registrator:
141-
image: gliderlabs/registrator:v7
142-
depends_on:
143-
- consul
144-
hostname: registrator
145-
volumes:
146-
- "/var/run/docker.sock:/tmp/docker.sock"
147-
command: -internal consul://consul:8500
148-
restart: always
149-
environment:
150-
- "affinity:com.mariadb.host!=registrator"
151-
labels:
152-
- "com.mariadb.host=registrator"
153-
consul:
154-
image: "progrium/consul:latest"
155-
hostname: "consul"
156-
ports:
157-
- "8400:8400"
158-
- "8500:8500"
159-
- "8600:53/udp"
160-
command: "-server -bootstrap -ui-dir /ui"
161-
restart: always
162-
vizualizer:
163-
image: bstaijen/mariadb-microservice-vizualizersvc:demo
164-
ports:
165-
- 3000:3000
166-
environment:
167-
- SWARM_HOST
168-
- SWARM_CA
169-
- SWARM_KEY
170-
- SWARM_CERT
171-
- "constraint:node==master"
172-
restart: always
128+

run.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -e
3+
4+
SWARM_MACHINE_NAME=master
5+
CERT_PATH=~/.docker/machine/machines/$SWARM_MACHINE_NAME
6+
export SWARM_CA=$(cat $CERT_PATH/ca.pem)
7+
export SWARM_CERT=$(cat $CERT_PATH/cert.pem)
8+
export SWARM_KEY=$(cat $CERT_PATH/key.pem)
9+
export SWARM_HOST=tcp://$(docker-machine ip $SWARM_MACHINE_NAME):3376
10+
11+
# Start running containers in the cluster and make
12+
# sure that registrator is running on each of them
13+
docker-compose up -d --force-recreate
14+
docker-compose scale registrator=3

scripts/build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ docker build -t authenticationsvc ../authentication-service
77
docker build -t photosvc ../photo-service
88
docker build -t votesvc ../vote-service
99
docker build -t commentsvc ../comment-service
10-
docker build -t profilesvc ../profile-service
10+
docker build -t profilesvc ../profile-service
11+
docker build -t vizualizersvc ../vizualizer
12+
docker build -t db ../database

scripts/create_swarm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ docker-machine create \
2424
--engine-opt="cluster-advertise=eth1:2376" master
2525

2626
# Create 4 nodes
27-
for N in 0 1 2 3; do
27+
for N in 0 1; do
2828
docker-machine create \
2929
--driver virtualbox \
3030
--virtualbox-memory 512 \

scripts/run.sh

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

start_registrator.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -e
3+
4+
SWARM_MACHINE_NAME=master
5+
CERT_PATH=~/.docker/machine/machines/$SWARM_MACHINE_NAME
6+
export SWARM_CA=$(cat $CERT_PATH/ca.pem)
7+
export SWARM_CERT=$(cat $CERT_PATH/cert.pem)
8+
export SWARM_KEY=$(cat $CERT_PATH/key.pem)
9+
export SWARM_HOST=tcp://$(docker-machine ip $SWARM_MACHINE_NAME):3376
10+
11+
# Start running containers in the cluster and make
12+
# sure that registrator is running on each of them
13+
docker-compose -f docker-compose-registrator.yml up -d
14+
docker-compose -f docker-compose-registrator.yml scale registrator=3

vote-service/app/http/controllers/controllers.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ func GetVotesFromAUser(connection *sql.DB, cnf config.Config) negroni.HandlerFun
8989
}
9090

9191
if len(queryToken) < 1 {
92-
w.WriteHeader(http.StatusBadRequest)
93-
w.Write([]byte(string("token is mandatory")))
92+
util.SendErrorMessage(w, "Token is mandatory")
9493
return
9594
}
9695

@@ -105,7 +104,7 @@ func GetVotesFromAUser(connection *sql.DB, cnf config.Config) negroni.HandlerFun
105104
}
106105

107106
claims := tok.Claims.(jwt.MapClaims)
108-
var ID = claims["sub"].(float64) // gets the ID
107+
var ID = claims["sub"].(float64) // gets the UserID
109108

110109
// get offset and rows
111110
offset, rows := helper.PaginationFromRequest(r)
@@ -118,7 +117,6 @@ func GetVotesFromAUser(connection *sql.DB, cnf config.Config) negroni.HandlerFun
118117

119118
photos := getPhotos(cnf, photoIDs)
120119

121-
// TODO : put this in a method.
122120
t := make([]*sharedModels.HasVotedRequest, 0)
123121
g := make([]*sharedModels.VoteCountRequest, 0)
124122
for _, v := range photos {

0 commit comments

Comments
 (0)