From 73be5f3815b8a94255d4fad0effcc3b406aa8ab6 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 17 Jul 2019 12:39:41 +0000 Subject: [PATCH 01/57] generators working but incomplete --- Dockerfile | 0 num_gen/Dockerfile | 4 ++++ num_gen/num_gen.py | 11 +++++++++++ num_gen/num_gen.py.save | 10 ++++++++++ prize_gen/Dockerfile | 5 +++++ prize_gen/prize_gen.py | 18 ++++++++++++++++++ server/Dockerfile | 0 text_gen/Dockerfile | 4 ++++ text_gen/text_gen.py | 13 +++++++++++++ 9 files changed, 65 insertions(+) create mode 100644 Dockerfile create mode 100644 num_gen/Dockerfile create mode 100644 num_gen/num_gen.py create mode 100644 num_gen/num_gen.py.save create mode 100644 prize_gen/Dockerfile create mode 100644 prize_gen/prize_gen.py create mode 100644 server/Dockerfile create mode 100644 text_gen/Dockerfile create mode 100644 text_gen/text_gen.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e69de29 diff --git a/num_gen/Dockerfile b/num_gen/Dockerfile new file mode 100644 index 0000000..672e3ea --- /dev/null +++ b/num_gen/Dockerfile @@ -0,0 +1,4 @@ +FROM python +COPY . . +RUN pip install flask +ENTRYPOINT ["python", "num_gen.py"] diff --git a/num_gen/num_gen.py b/num_gen/num_gen.py new file mode 100644 index 0000000..8df791b --- /dev/null +++ b/num_gen/num_gen.py @@ -0,0 +1,11 @@ +from flask import Flask, jsonify, make_response +from random import randint +num_gen = Flask(__name__) + +@num_gen.route('/num_gen/', methods=['GET']) +def num_gen_method(): + rand = randint(100000,999999) + return jsonify({"Random Number":rand}) + +if __name__ == '__main__': + num_gen.run(host='0.0.0.0', port=9017) diff --git a/num_gen/num_gen.py.save b/num_gen/num_gen.py.save new file mode 100644 index 0000000..371181d --- /dev/null +++ b/num_gen/num_gen.py.save @@ -0,0 +1,10 @@ +from flask import Flask, jsonify, make_response +from random import randint +num_gen = Flask(__name__) + +@num_gen.route('/num_gen/', methods=['GET']) +def num_gen_method(999999): + rand = randint(100000,999999) + return jsonify({"Random Number":rand}) + + diff --git a/prize_gen/Dockerfile b/prize_gen/Dockerfile new file mode 100644 index 0000000..96e8787 --- /dev/null +++ b/prize_gen/Dockerfile @@ -0,0 +1,5 @@ +FROM python:latest +COPY . . +RUN pip install flask +RUN pip install requests +ENTRYPOINT ["python", "prize_gen.py"] diff --git a/prize_gen/prize_gen.py b/prize_gen/prize_gen.py new file mode 100644 index 0000000..4a491c2 --- /dev/null +++ b/prize_gen/prize_gen.py @@ -0,0 +1,18 @@ +from flask import Flask, jsonify, make_response +import random +from random import randrange +prize_gen = Flask(__name__) + + +@prize_gen.route('/prize_gen/', methods=['GET']) +def reset(prob=25): + prize=50 + percent = random.randrange(100) + if prob > percent: + return jsonify({"User has won":prize}) + else: + return "No prize for you" + + +if __name__ == '__main__': + prize_gen.run(host='0.0.0.0', port=5000) diff --git a/server/Dockerfile b/server/Dockerfile new file mode 100644 index 0000000..e69de29 diff --git a/text_gen/Dockerfile b/text_gen/Dockerfile new file mode 100644 index 0000000..179d0c9 --- /dev/null +++ b/text_gen/Dockerfile @@ -0,0 +1,4 @@ +FROM python +COPY . . +RUN pip install flask +ENTRYPOINT ["python", "text_gen.py"] diff --git a/text_gen/text_gen.py b/text_gen/text_gen.py new file mode 100644 index 0000000..8a39c52 --- /dev/null +++ b/text_gen/text_gen.py @@ -0,0 +1,13 @@ +from flask import Flask, jsonify, make_response +import random +import string +text_gen = Flask(__name__) + + +@text_gen.route('/text_gen/', methods=['GET']) +def text_gen_method(): + rand = random.choice(string.ascii_lowercase) + return jsonify({"Random string":rand}) + +if __name__ == '__main__': + text_gen.run(host='0.0.0.0', port=9017) From 1737e2e98d09d3b44db96af1ebdc4cf8152354f9 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 17 Jul 2019 13:21:59 +0000 Subject: [PATCH 02/57] all implementations built --- num_gen/{num_gen.py => num_gen1.py} | 0 num_gen/{num_gen.py.save => num_gen2.py} | 7 ++++--- prize_gen/Dockerfile | 3 ++- prize_gen/{prize_gen.py => prize_gen1.py} | 0 prize_gen/prize_gen2.py | 18 ++++++++++++++++++ text_gen/{text_gen.py => text_gen1.py} | 3 ++- text_gen/text_gen2.py | 14 ++++++++++++++ 7 files changed, 40 insertions(+), 5 deletions(-) rename num_gen/{num_gen.py => num_gen1.py} (100%) rename num_gen/{num_gen.py.save => num_gen2.py} (59%) rename prize_gen/{prize_gen.py => prize_gen1.py} (100%) create mode 100644 prize_gen/prize_gen2.py rename text_gen/{text_gen.py => text_gen1.py} (78%) create mode 100644 text_gen/text_gen2.py diff --git a/num_gen/num_gen.py b/num_gen/num_gen1.py similarity index 100% rename from num_gen/num_gen.py rename to num_gen/num_gen1.py diff --git a/num_gen/num_gen.py.save b/num_gen/num_gen2.py similarity index 59% rename from num_gen/num_gen.py.save rename to num_gen/num_gen2.py index 371181d..42cf595 100644 --- a/num_gen/num_gen.py.save +++ b/num_gen/num_gen2.py @@ -3,8 +3,9 @@ num_gen = Flask(__name__) @num_gen.route('/num_gen/', methods=['GET']) -def num_gen_method(999999): - rand = randint(100000,999999) +def num_gen_method(): + rand = randint(10000000,99999999) return jsonify({"Random Number":rand}) - +if __name__ == '__main__': + num_gen.run(host='0.0.0.0', port=9017) diff --git a/prize_gen/Dockerfile b/prize_gen/Dockerfile index 96e8787..a5ceb27 100644 --- a/prize_gen/Dockerfile +++ b/prize_gen/Dockerfile @@ -1,5 +1,6 @@ +ARG FILE_VERSION=prize_gen1.py FROM python:latest COPY . . RUN pip install flask RUN pip install requests -ENTRYPOINT ["python", "prize_gen.py"] +ENTRYPOINT ["python", "${FILE_VERSION}"] diff --git a/prize_gen/prize_gen.py b/prize_gen/prize_gen1.py similarity index 100% rename from prize_gen/prize_gen.py rename to prize_gen/prize_gen1.py diff --git a/prize_gen/prize_gen2.py b/prize_gen/prize_gen2.py new file mode 100644 index 0000000..cdcfe9c --- /dev/null +++ b/prize_gen/prize_gen2.py @@ -0,0 +1,18 @@ +from flask import Flask, jsonify, make_response +import random +from random import randrange +prize_gen = Flask(__name__) + + +@prize_gen.route('/prize_gen/', methods=['GET']) +def reset(prob=25): + prize=100 + percent = random.randrange(100) + if prob > percent: + return jsonify({"User has won":prize}) + else: + return "No prize for you" + + +if __name__ == '__main__': + prize_gen.run(host='0.0.0.0', port=5000) diff --git a/text_gen/text_gen.py b/text_gen/text_gen1.py similarity index 78% rename from text_gen/text_gen.py rename to text_gen/text_gen1.py index 8a39c52..39bb4b4 100644 --- a/text_gen/text_gen.py +++ b/text_gen/text_gen1.py @@ -1,12 +1,13 @@ from flask import Flask, jsonify, make_response import random import string + text_gen = Flask(__name__) @text_gen.route('/text_gen/', methods=['GET']) def text_gen_method(): - rand = random.choice(string.ascii_lowercase) + rand = (''.join(random.choice(string.ascii_lowercase) for i in range(3))) return jsonify({"Random string":rand}) if __name__ == '__main__': diff --git a/text_gen/text_gen2.py b/text_gen/text_gen2.py new file mode 100644 index 0000000..1accd2a --- /dev/null +++ b/text_gen/text_gen2.py @@ -0,0 +1,14 @@ +from flask import Flask, jsonify, make_response +import random +import string + +text_gen = Flask(__name__) + + +@text_gen.route('/text_gen/', methods=['GET']) +def text_gen_method(): + rand = (''.join(random.choice(string.ascii_uppercase) for i in range(2))) + return jsonify({"Random string":rand}) + +if __name__ == '__main__': + text_gen.run(host='0.0.0.0', port=9017) From e70f58b487558206a86e8d152c524a656b4c5183 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 17 Jul 2019 14:46:47 +0000 Subject: [PATCH 03/57] args working for version implementation --- db_connector/Dockerfile | 3 +++ db_connector/config/keys.js | 2 +- docker-compose.yaml | 6 ++++++ num_gen/Dockerfile | 4 +++- num_gen/num_gen1.py | 2 +- num_gen/num_gen2.py | 2 +- prize_gen/Dockerfile | 7 ++++--- prize_gen/prize_gen1.py | 1 + text_gen/Dockerfile | 4 +++- 9 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 db_connector/Dockerfile create mode 100644 docker-compose.yaml diff --git a/db_connector/Dockerfile b/db_connector/Dockerfile new file mode 100644 index 0000000..28a03a8 --- /dev/null +++ b/db_connector/Dockerfile @@ -0,0 +1,3 @@ +FROM mongo:latest +COPY . . +ENTRYPOINT [] diff --git a/db_connector/config/keys.js b/db_connector/config/keys.js index e61b6ed..e95be00 100755 --- a/db_connector/config/keys.js +++ b/db_connector/config/keys.js @@ -1,4 +1,4 @@ module.exports = { - mongoURI: "mongodb://lafb:lafb123@ds165632.mlab.com:63835/accounts" + mongoURI: "mongodb://23b18f2e852d:63835/accounts" }; diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..ff5a580 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,6 @@ +version: '3.7' +services: + mongo: + image: mongo + ports: + - "27017:27017" diff --git a/num_gen/Dockerfile b/num_gen/Dockerfile index 672e3ea..d19a2de 100644 --- a/num_gen/Dockerfile +++ b/num_gen/Dockerfile @@ -1,4 +1,6 @@ FROM python +ARG FILE_VERSION=1 COPY . . +COPY num_gen${FILE_VERSION}.py app.py RUN pip install flask -ENTRYPOINT ["python", "num_gen.py"] +ENTRYPOINT ["python", "app.py"] diff --git a/num_gen/num_gen1.py b/num_gen/num_gen1.py index 8df791b..6c23b98 100644 --- a/num_gen/num_gen1.py +++ b/num_gen/num_gen1.py @@ -8,4 +8,4 @@ def num_gen_method(): return jsonify({"Random Number":rand}) if __name__ == '__main__': - num_gen.run(host='0.0.0.0', port=9017) + num_gen.run(host='0.0.0.0', port=9018) diff --git a/num_gen/num_gen2.py b/num_gen/num_gen2.py index 42cf595..f885bed 100644 --- a/num_gen/num_gen2.py +++ b/num_gen/num_gen2.py @@ -8,4 +8,4 @@ def num_gen_method(): return jsonify({"Random Number":rand}) if __name__ == '__main__': - num_gen.run(host='0.0.0.0', port=9017) + num_gen.run(host='0.0.0.0', port=9018) diff --git a/prize_gen/Dockerfile b/prize_gen/Dockerfile index a5ceb27..40a7f9a 100644 --- a/prize_gen/Dockerfile +++ b/prize_gen/Dockerfile @@ -1,6 +1,7 @@ -ARG FILE_VERSION=prize_gen1.py -FROM python:latest +FROM python +ARG FILE_VERSION=1 COPY . . +COPY prize_gen${FILE_VERSION}.py app.py RUN pip install flask RUN pip install requests -ENTRYPOINT ["python", "${FILE_VERSION}"] +ENTRYPOINT ["python", "app.py"] diff --git a/prize_gen/prize_gen1.py b/prize_gen/prize_gen1.py index 4a491c2..a256247 100644 --- a/prize_gen/prize_gen1.py +++ b/prize_gen/prize_gen1.py @@ -9,6 +9,7 @@ def reset(prob=25): prize=50 percent = random.randrange(100) if prob > percent: + return jsonify({"User has won":prize}) else: return "No prize for you" diff --git a/text_gen/Dockerfile b/text_gen/Dockerfile index 179d0c9..da32481 100644 --- a/text_gen/Dockerfile +++ b/text_gen/Dockerfile @@ -1,4 +1,6 @@ FROM python +ARG FILE_VERSION=1 COPY . . +COPY text_gen${FILE_VERSION}.py app.py RUN pip install flask -ENTRYPOINT ["python", "text_gen.py"] +ENTRYPOINT ["python", "app.py"] From c37449102c564b99e16adae6b5cfd7bd43cfc3eb Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 17 Jul 2019 15:06:55 +0000 Subject: [PATCH 04/57] get request workingggg --- prize_gen/prize_gen1.py | 3 ++- prize_gen/prize_gen2.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/prize_gen/prize_gen1.py b/prize_gen/prize_gen1.py index a256247..5f72422 100644 --- a/prize_gen/prize_gen1.py +++ b/prize_gen/prize_gen1.py @@ -1,5 +1,6 @@ from flask import Flask, jsonify, make_response import random +import requests from random import randrange prize_gen = Flask(__name__) @@ -9,7 +10,7 @@ def reset(prob=25): prize=50 percent = random.randrange(100) if prob > percent: - + request.get('http://52.142.204.121:9000/notify') return jsonify({"User has won":prize}) else: return "No prize for you" diff --git a/prize_gen/prize_gen2.py b/prize_gen/prize_gen2.py index cdcfe9c..49fd39d 100644 --- a/prize_gen/prize_gen2.py +++ b/prize_gen/prize_gen2.py @@ -1,5 +1,6 @@ from flask import Flask, jsonify, make_response import random +import requests from random import randrange prize_gen = Flask(__name__) @@ -9,6 +10,7 @@ def reset(prob=25): prize=100 percent = random.randrange(100) if prob > percent: + request.get('http://52.142.204.121:9000/notify') return jsonify({"User has won":prize}) else: return "No prize for you" From 3368e012cee93f310552d119d10fa6157db99d9a Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 17 Jul 2019 16:04:27 +0000 Subject: [PATCH 05/57] working on connector image --- db_connector/Dockerfile | 7 +++++-- db_connector/config/keys.js | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/db_connector/Dockerfile b/db_connector/Dockerfile index 28a03a8..cebeb4e 100644 --- a/db_connector/Dockerfile +++ b/db_connector/Dockerfile @@ -1,3 +1,6 @@ -FROM mongo:latest + +FROM node:10 as node-build +WORKDIR /build COPY . . -ENTRYPOINT [] +RUN npm install +ENTRYPOINT ["server.js", "-l", "5001"] diff --git a/db_connector/config/keys.js b/db_connector/config/keys.js index e95be00..c333c2a 100755 --- a/db_connector/config/keys.js +++ b/db_connector/config/keys.js @@ -1,4 +1,3 @@ module.exports = { - mongoURI: "mongodb://23b18f2e852d:63835/accounts" + mongoURI: "mongodb://mongo:27017/account" }; - From b9e199e95ef170e77040fbba7628d30c6e2d4946 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 18 Jul 2019 08:18:41 +0000 Subject: [PATCH 06/57] db connect and static website containers up --- db_connector/Dockerfile | 7 +++---- prize_gen/prize_gen1.py | 2 +- prize_gen/prize_gen2.py | 2 +- static_website/Dockerfile | 5 +++++ 4 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 static_website/Dockerfile diff --git a/db_connector/Dockerfile b/db_connector/Dockerfile index cebeb4e..aa341f2 100644 --- a/db_connector/Dockerfile +++ b/db_connector/Dockerfile @@ -1,6 +1,5 @@ - -FROM node:10 as node-build -WORKDIR /build +FROM node:10 COPY . . RUN npm install -ENTRYPOINT ["server.js", "-l", "5001"] +EXPOSE 5001 +ENTRYPOINT ["node", "server.js"] diff --git a/prize_gen/prize_gen1.py b/prize_gen/prize_gen1.py index 5f72422..143a618 100644 --- a/prize_gen/prize_gen1.py +++ b/prize_gen/prize_gen1.py @@ -10,7 +10,7 @@ def reset(prob=25): prize=50 percent = random.randrange(100) if prob > percent: - request.get('http://52.142.204.121:9000/notify') + request.get('http://localhost:9000/notify') return jsonify({"User has won":prize}) else: return "No prize for you" diff --git a/prize_gen/prize_gen2.py b/prize_gen/prize_gen2.py index 49fd39d..eeb849a 100644 --- a/prize_gen/prize_gen2.py +++ b/prize_gen/prize_gen2.py @@ -10,7 +10,7 @@ def reset(prob=25): prize=100 percent = random.randrange(100) if prob > percent: - request.get('http://52.142.204.121:9000/notify') + request.get('http://localhost:9000/notify') return jsonify({"User has won":prize}) else: return "No prize for you" diff --git a/static_website/Dockerfile b/static_website/Dockerfile new file mode 100644 index 0000000..2621877 --- /dev/null +++ b/static_website/Dockerfile @@ -0,0 +1,5 @@ +FROM node:10 +COPY . . +RUN npm install +EXPOSE 8089 +ENTRYPOINT ["node", "server.js"] From 818254119ac8f1d7ad73d5a28ae3fb2adb6d5c35 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 18 Jul 2019 09:24:52 +0000 Subject: [PATCH 07/57] dockerised server on own container --- Dockerfile | 0 docker-compose.yaml | 32 ++++++++++++++++++++++++++++++++ nginx.conf | 12 ++++++++++++ notification_server/Dockerfile | 4 ++++ server/Dockerfile | 8 ++++++++ 5 files changed, 56 insertions(+) delete mode 100644 Dockerfile create mode 100644 nginx.conf create mode 100644 notification_server/Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index e69de29..0000000 diff --git a/docker-compose.yaml b/docker-compose.yaml index ff5a580..ae8f8c3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,5 +1,37 @@ version: '3.7' services: + nginx: + image: nginx + depends_on: + - client + - server + volumes: + - type: bind + source: ./nginx.conf + target: /etc/nginx/nginx.conf + ports: + - target: 80 + protocol: tcp + published: 80 + container_name: nginx + + server: + image: keepkarm/server:latest + build: + context: ./server + dockerfile: Dockerfile + ports: + - "8082:8084" + + client: + image: kryan1622/kube/my/client:latest + build: + context: ./client + dockerfile: Dockerfile + ports: + - "3001:3000" + + mongo: image: mongo ports: diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..98c89e8 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,12 @@ +events {} +http { + server { + listen 80; + location / { + proxy_pass http://client:8089/; + } + location /server/ { + proxy_pass http://server:8084/; + } + } +} diff --git a/notification_server/Dockerfile b/notification_server/Dockerfile new file mode 100644 index 0000000..9b28a84 --- /dev/null +++ b/notification_server/Dockerfile @@ -0,0 +1,4 @@ +FROM python +COPY . . +RUN pip install flask +ENTRYPOINT ["python", "app.py"] diff --git a/server/Dockerfile b/server/Dockerfile index e69de29..d93626e 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -0,0 +1,8 @@ +FROM maven:latest as maven-build +WORKDIR /build +COPY . . +RUN mvn clean package +FROM java:8 +WORKDIR /opt/website +COPY --from=maven-build /build/target/Spring_Day_Two-0.0.1-SNAPSHOT.jar app.jar +ENTRYPOINT ["/usr/bin/java", "-jar", "app.jar"] From 310c45d8f476b96067839416f4998e05fc5d35bf Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 18 Jul 2019 11:14:39 +0000 Subject: [PATCH 08/57] containers running but not communicating with docker-compose --- Do | 0 docker-compose.yaml | 47 +++++++++++++++++-- .../src/main/resources/application.properties | 6 +-- 3 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 Do diff --git a/Do b/Do new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yaml b/docker-compose.yaml index ae8f8c3..2660b4d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -21,16 +21,55 @@ services: context: ./server dockerfile: Dockerfile ports: - - "8082:8084" + - "8084:8084" client: - image: kryan1622/kube/my/client:latest + image: keepkarm/client:latest build: - context: ./client + context: ./static_website dockerfile: Dockerfile ports: - - "3001:3000" + - "8089:8089" + notify: + image: keepkarm/notify:latest + build: + context: ./notification_server + dockerfile: Dockerfile + ports: + - "9000:9000" + + text_gen: + image: keepkarm/text_gen:v1 + build: + context: ./text_gen + dockerfile: Dockerfile + ports: + - "9017:9017" + + num_gen: + image: keepkarm/num_gen:v1 + build: + context: ./num_gen + dockerfile: Dockerfile + ports: + - "9018:9018" + + prize_gen: + image: keepkarm/prize_gen:v1 + build: + context: ./prize_gen + dockerfile: Dockerfile + ports: + - "5000:5000" + + db_connector: + image: keepkarm/db_connect:latest + build: + context: ./db_connector + dockerfile: Dockerfile + ports: + - "5001:5001" mongo: image: mongo diff --git a/server/src/main/resources/application.properties b/server/src/main/resources/application.properties index 9d60327..0410e67 100644 --- a/server/src/main/resources/application.properties +++ b/server/src/main/resources/application.properties @@ -3,6 +3,6 @@ spring.main.allow-bean-definition-overriding=true server.port=8084 url.getAll=http://localhost:5001/account/all -url.textGen= ??? -url.numGen= ??? -url.prize= ??? +url.textGen=http://localhost:9017/text_gen +url.numGen=http://localhost:9018/num_gen +url.prize=http://localhost:5000/prize_gen From dda3280b471c32dc8f4b51fbb9961e35495c8675 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 18 Jul 2019 14:35:50 +0000 Subject: [PATCH 09/57] database persisting --- Do | 0 account/.dockerignore | 1 + account/Dockerfile | 9 + account/package-lock.json | 670 +++++++++++++++++++++++++++++++ account/package.json | 19 + account/routes/account1.js | 71 ++++ account/routes/account2.js | 71 ++++ account/server.js | 15 + docker-compose.yaml | 19 +- static_website/public/index.html | 7 +- static_website/public/script.js | 18 + 11 files changed, 888 insertions(+), 12 deletions(-) delete mode 100644 Do create mode 100644 account/.dockerignore create mode 100644 account/Dockerfile create mode 100644 account/package-lock.json create mode 100644 account/package.json create mode 100644 account/routes/account1.js create mode 100644 account/routes/account2.js create mode 100644 account/server.js diff --git a/Do b/Do deleted file mode 100644 index e69de29..0000000 diff --git a/account/.dockerignore b/account/.dockerignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/account/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/account/Dockerfile b/account/Dockerfile new file mode 100644 index 0000000..776f97e --- /dev/null +++ b/account/Dockerfile @@ -0,0 +1,9 @@ +FROM node:10 +ARG FILE_VERSION=1 +WORKDIR /usr/src/app +COPY package*.json ./ +RUN npm install +COPY . . +COPY routes/account${FILE_VERSION}.js routes/account.js +EXPOSE 5002 +ENTRYPOINT [ "node", "server.js" ] diff --git a/account/package-lock.json b/account/package-lock.json new file mode 100644 index 0000000..094f960 --- /dev/null +++ b/account/package-lock.json @@ -0,0 +1,670 @@ +{ + "name": "discussion_board_example", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "requires": { + "mime-types": "~2.1.24", + "negotiator": "0.6.2" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", + "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", + "requires": { + "lodash": "^4.17.10" + } + }, + "axios": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", + "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", + "requires": { + "follow-redirects": "1.5.10", + "is-buffer": "^2.0.2" + } + }, + "bcryptjs": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", + "integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=" + }, + "bluebird": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" + }, + "body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "requires": { + "bytes": "3.1.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + } + }, + "bson": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.1.tgz", + "integrity": "sha512-jCGVYLoYMHDkOsbwJZBCqwMHyH4c+wzgI9hG7Z6SZJRXWr+x58pdIbm2i9a/jFGCkRJqRUr8eoI7lDWa0hTkxg==" + }, + "bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "express": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", + "integrity": "sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg==", + "requires": { + "accepts": "~1.3.5", + "array-flatten": "1.1.1", + "body-parser": "1.18.3", + "content-disposition": "0.5.2", + "content-type": "~1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.1.1", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.4", + "qs": "6.5.2", + "range-parser": "~1.2.0", + "safe-buffer": "5.1.2", + "send": "0.16.2", + "serve-static": "1.13.2", + "setprototypeof": "1.1.0", + "statuses": "~1.4.0", + "type-is": "~1.6.16", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "dependencies": { + "body-parser": { + "version": "1.18.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", + "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "~1.6.3", + "iconv-lite": "0.4.23", + "on-finished": "~2.3.0", + "qs": "6.5.2", + "raw-body": "2.3.3", + "type-is": "~1.6.16" + } + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + }, + "iconv-lite": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", + "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "raw-body": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", + "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.3", + "iconv-lite": "0.4.23", + "unpipe": "1.0.0" + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + } + } + }, + "finalhandler": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "statuses": "~1.4.0", + "unpipe": "~1.0.0" + }, + "dependencies": { + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + } + } + }, + "follow-redirects": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", + "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", + "requires": { + "debug": "=3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ipaddr.js": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", + "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==" + }, + "is-buffer": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", + "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" + }, + "kareem": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.0.tgz", + "integrity": "sha512-6hHxsp9e6zQU8nXsP+02HGWXwTkOEw6IROhF2ZA28cYbUk4eJ6QbtZvdqZOdD9YPKghG3apk5eOCvs+tLl3lRg==" + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", + "optional": true + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + }, + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "requires": { + "mime-db": "1.40.0" + } + }, + "mongodb": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.3.tgz", + "integrity": "sha512-jw8UyPsq4QleZ9z+t/pIVy3L++51vKdaJ2Q/XXeYxk/3cnKioAH8H6f5tkkDivrQL4PUgUOHe9uZzkpRFH1XtQ==", + "requires": { + "mongodb-core": "^3.2.3", + "safe-buffer": "^5.1.2" + } + }, + "mongodb-core": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.2.3.tgz", + "integrity": "sha512-UyI0rmvPPkjOJV8XGWa9VCTq7R4hBVipimhnAXeSXnuAPjuTqbyfA5Ec9RcYJ1Hhu+ISnc8bJ1KfGZd4ZkYARQ==", + "requires": { + "bson": "^1.1.1", + "require_optional": "^1.0.1", + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" + } + }, + "mongoose": { + "version": "5.5.6", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.5.6.tgz", + "integrity": "sha512-XbCVIQTQgzRAPLc8t8Tw5l/uTzdRV6lDnR7Q8KCsXnaX4D1tEFybtWxesidn4WkrGi67PiIWzu5Lsu7SwKkYug==", + "requires": { + "async": "2.6.1", + "bson": "~1.1.1", + "kareem": "2.3.0", + "mongodb": "3.2.3", + "mongodb-core": "3.2.3", + "mongoose-legacy-pluralize": "1.0.2", + "mpath": "0.6.0", + "mquery": "3.2.0", + "ms": "2.1.1", + "regexp-clone": "0.0.1", + "safe-buffer": "5.1.2", + "sift": "7.0.1", + "sliced": "1.0.1" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } + } + }, + "mongoose-legacy-pluralize": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz", + "integrity": "sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ==" + }, + "mpath": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.6.0.tgz", + "integrity": "sha512-i75qh79MJ5Xo/sbhxrDrPSEG0H/mr1kcZXJ8dH6URU5jD/knFxCVqVC/gVSW7GIXL/9hHWlT9haLbCXWOll3qw==" + }, + "mquery": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.0.tgz", + "integrity": "sha512-qPJcdK/yqcbQiKoemAt62Y0BAc0fTEKo1IThodBD+O5meQRJT/2HSe5QpBNwaa4CjskoGrYWsEyjkqgiE0qjhg==", + "requires": { + "bluebird": "3.5.1", + "debug": "3.1.0", + "regexp-clone": "0.0.1", + "safe-buffer": "5.1.2", + "sliced": "1.0.1" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "negotiator": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "proxy-addr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", + "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.9.0" + } + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + }, + "raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "requires": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } + }, + "regexp-clone": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz", + "integrity": "sha1-p8LgmJH9vzj7sQ03b7cwA+aKxYk=" + }, + "require_optional": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", + "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==", + "requires": { + "resolve-from": "^2.0.0", + "semver": "^5.1.0" + } + }, + "resolve-from": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", + "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=" + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "saslprep": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz", + "integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==", + "optional": true, + "requires": { + "sparse-bitfield": "^3.0.3" + } + }, + "semver": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" + }, + "send": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", + "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.6.2", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "~2.3.0", + "range-parser": "~1.2.0", + "statuses": "~1.4.0" + }, + "dependencies": { + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + } + } + }, + "serve-static": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", + "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.2", + "send": "0.16.2" + } + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + }, + "sift": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz", + "integrity": "sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g==" + }, + "sliced": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", + "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" + }, + "sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=", + "optional": true, + "requires": { + "memory-pager": "^1.0.2" + } + }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "validator": { + "version": "10.11.0", + "resolved": "https://registry.npmjs.org/validator/-/validator-10.11.0.tgz", + "integrity": "sha512-X/p3UZerAIsbBfN/IwahhYaBbY68EN/UQBWHtsbXGT5bfrH/p4NQzUCG1kF/rtKaNpnJ7jAu6NGTdSNtyNIXMw==" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + } + } +} diff --git a/account/package.json b/account/package.json new file mode 100644 index 0000000..ea3ce10 --- /dev/null +++ b/account/package.json @@ -0,0 +1,19 @@ +{ + "name": "discussion_board_example", + "version": "1.0.0", + "description": "Samples of the Discussion Board Project", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Matt Hunt", + "license": "ISC", + "dependencies": { + "axios": "^0.19.0", + "bcryptjs": "^2.4.3", + "body-parser": "^1.19.0", + "express": "^4.16.4", + "mongoose": "^5.5.6", + "validator": "^10.11.0" + } +} diff --git a/account/routes/account1.js b/account/routes/account1.js new file mode 100644 index 0000000..c07291b --- /dev/null +++ b/account/routes/account1.js @@ -0,0 +1,71 @@ +const express = require("express"); +const router = express.Router(); +const axios = require('axios'); + +// @route GET account/test +// @desc Tests route +// @access Public +router.get("/test", (req, res) => { + res.json({ + message: "account" + }); +}); + +// @route GET account/all +// @desc Get all accounts +// @access Public + +router.get("/all", (req, res) => { + + axios.get('http://db_connector:5001/account/all') + .then(response => { + +res.send(response.data) + }) + .catch(error => { + console.log(error); + }); + + +}); + +// @route POST account/createaccount +// @desc Create an account +// @access Public +router.post("/createAccount", (req, res) => { + + let prizeDecider = Math.floor(Math.random() * 100); + let prize; + + if (prizeDecider >= 75){ + prize = "£50"; + + axios.get('http://notificationserver:9000/notify').catch(error => { + console.log(error); + }); + + }else{ + prize = "No Prize" + } + + const newAccount = { + firstName: req.body.firstName, + lastName: req.body.lastName, + accountnumber: req.body.accountnumber, + prize: prize + }; + + axios.post('http://db_connector:5001/account/createAccount', newAccount) + .then(response => { + + res.send(response.data); + + }) .catch(error => { + console.log(error); + }); + + + +}); + +module.exports = router; diff --git a/account/routes/account2.js b/account/routes/account2.js new file mode 100644 index 0000000..5e1a0b1 --- /dev/null +++ b/account/routes/account2.js @@ -0,0 +1,71 @@ +const express = require("express"); +const router = express.Router(); +const axios = require('axios'); + +// @route GET account/test +// @desc Tests route +// @access Public +router.get("/test", (req, res) => { + res.json({ + message: "account" + }); +}); + +// @route GET account/all +// @desc Get all accounts +// @access Public + +router.get("/all", (req, res) => { + + axios.get('http://db_connector:5001/account/all') + .then(response => { + +res.send(response.data) + }) + .catch(error => { + console.log(error); + }); + + +}); + +// @route POST account/createaccount +// @desc Create an account +// @access Public +router.post("/createAccount", (req, res) => { + + let prizeDecider = Math.floor(Math.random() * 100); + let prize; + + if (prizeDecider >= 75){ + prize = "£100"; + + axios.get('http://notificationserver:9000/notify').catch(error => { + console.log(error); + }); + + }else{ + prize = "No Prize" + } + + const newAccount = { + firstName: req.body.firstName, + lastName: req.body.lastName, + accountnumber: req.body.accountnumber, + prize: prize + }; + + axios.post('http://db_connector:5001/account/createAccount', newAccount) + .then(response => { + + res.send(response.data); + + }) .catch(error => { + console.log(error); + }); + + + +}); + +module.exports = router; diff --git a/account/server.js b/account/server.js new file mode 100644 index 0000000..03438f0 --- /dev/null +++ b/account/server.js @@ -0,0 +1,15 @@ +const express = require("express"); +const bodyParser = require("body-parser"); + +const account = require("./routes/account"); + +const app = express(); + +app.use(bodyParser.urlencoded({ extended: false })); +app.use(bodyParser.json()); + +app.use("/account", account); + +const port = process.env.PORT || 5002; + +app.listen(port, () => console.log(`server running on port ${port}`)); diff --git a/docker-compose.yaml b/docker-compose.yaml index 2660b4d..e5bff43 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -55,21 +55,22 @@ services: ports: - "9018:9018" - prize_gen: - image: keepkarm/prize_gen:v1 + account: + image: keepkarm/account:v1 build: - context: ./prize_gen + context: ./account dockerfile: Dockerfile ports: - - "5000:5000" + - "5002:5002" db_connector: - image: keepkarm/db_connect:latest - build: - context: ./db_connector - dockerfile: Dockerfile + image: keepkarm/db_connector:latest ports: - - "5001:5001" + - target: 5001 + published: 5001 + protocol: tcp + depends_on: + - mongo mongo: image: mongo diff --git a/static_website/public/index.html b/static_website/public/index.html index 2c753ca..b17b125 100644 --- a/static_website/public/index.html +++ b/static_website/public/index.html @@ -9,13 +9,14 @@

Landing Page

- +
- +
- +
+ diff --git a/static_website/public/script.js b/static_website/public/script.js index e69de29..385319f 100644 --- a/static_website/public/script.js +++ b/static_website/public/script.js @@ -0,0 +1,18 @@ +function createAccount() { + let account = { + firstName: document.getElementById('firstNameForm').value, + lastName: document.getElementById('lastNameForm').value + } + + let req = new XMLHttpRequest(); + + req.onload = function () { + let response = JSON.parse(req.response); + console.log(response); + + } + req.open("POST", "http://localhost:5002/account/test"); + req.send(JSON.stringify(account)); + return console.log(response.text); +} + From 36cedf10507e0f65be5b82955ebf7f15bc8c3f0d Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 18 Jul 2019 15:46:27 +0000 Subject: [PATCH 10/57] endpoints all working --- docker-compose.yaml | 2 +- server/src/main/resources/application.properties | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index e5bff43..8eeb8e1 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -31,7 +31,7 @@ services: ports: - "8089:8089" - notify: + notificationserver: image: keepkarm/notify:latest build: context: ./notification_server diff --git a/server/src/main/resources/application.properties b/server/src/main/resources/application.properties index 0410e67..ed4c313 100644 --- a/server/src/main/resources/application.properties +++ b/server/src/main/resources/application.properties @@ -1,8 +1,9 @@ + spring.main.allow-bean-definition-overriding=true server.port=8084 -url.getAll=http://localhost:5001/account/all -url.textGen=http://localhost:9017/text_gen -url.numGen=http://localhost:9018/num_gen -url.prize=http://localhost:5000/prize_gen +url.getAll=http://account:5002/account/all +url.textGen=http://text_gen:9017/text_gen +url.numGen=http://num_gen:9018/num_gen +url.prize=http://account:5002/account/createAccount From dc84be552838f4a169a8ec151689ff30fed4cfbe Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 18 Jul 2019 17:34:05 +0000 Subject: [PATCH 11/57] frontend functions created --- docker-compose.yaml | 23 +++++++++++++++++------ num_gen/num_gen1.py | 4 ++-- num_gen/num_gen2.py | 4 ++-- static_website/public/index.html | 2 +- static_website/public/script.js | 11 ++++++----- text_gen/text_gen1.py | 4 ++-- text_gen/text_gen2.py | 4 ++-- 7 files changed, 32 insertions(+), 20 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 8eeb8e1..9440b39 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,4 +1,4 @@ -version: '3.7' +version: '3.3' services: nginx: image: nginx @@ -22,6 +22,8 @@ services: dockerfile: Dockerfile ports: - "8084:8084" + depends_on: + - account client: image: keepkarm/client:latest @@ -38,6 +40,8 @@ services: dockerfile: Dockerfile ports: - "9000:9000" + depends_on: + - account text_gen: image: keepkarm/text_gen:v1 @@ -46,6 +50,8 @@ services: dockerfile: Dockerfile ports: - "9017:9017" + depends_on: + - server num_gen: image: keepkarm/num_gen:v1 @@ -54,6 +60,8 @@ services: dockerfile: Dockerfile ports: - "9018:9018" + depends_on: + - server account: image: keepkarm/account:v1 @@ -62,15 +70,18 @@ services: dockerfile: Dockerfile ports: - "5002:5002" + depends_on: + - db_connector db_connector: - image: keepkarm/db_connector:latest + image: keepkarm/db_connect:latest + build: + context: ./db_connector + dockerfile: Dockerfile ports: - - target: 5001 - published: 5001 - protocol: tcp + - "5001:5001" depends_on: - - mongo + - mongo mongo: image: mongo diff --git a/num_gen/num_gen1.py b/num_gen/num_gen1.py index 6c23b98..496dc50 100644 --- a/num_gen/num_gen1.py +++ b/num_gen/num_gen1.py @@ -2,10 +2,10 @@ from random import randint num_gen = Flask(__name__) -@num_gen.route('/num_gen/', methods=['GET']) +@num_gen.route('/num_gen/') def num_gen_method(): rand = randint(100000,999999) - return jsonify({"Random Number":rand}) + return str(rand) if __name__ == '__main__': num_gen.run(host='0.0.0.0', port=9018) diff --git a/num_gen/num_gen2.py b/num_gen/num_gen2.py index f885bed..f07d254 100644 --- a/num_gen/num_gen2.py +++ b/num_gen/num_gen2.py @@ -2,10 +2,10 @@ from random import randint num_gen = Flask(__name__) -@num_gen.route('/num_gen/', methods=['GET']) +@num_gen.route('/num_gen/') def num_gen_method(): rand = randint(10000000,99999999) - return jsonify({"Random Number":rand}) + return (rand) if __name__ == '__main__': num_gen.run(host='0.0.0.0', port=9018) diff --git a/static_website/public/index.html b/static_website/public/index.html index b17b125..242159a 100644 --- a/static_website/public/index.html +++ b/static_website/public/index.html @@ -13,7 +13,7 @@

Landing Page



- + diff --git a/static_website/public/script.js b/static_website/public/script.js index 385319f..cdb1c3e 100644 --- a/static_website/public/script.js +++ b/static_website/public/script.js @@ -2,17 +2,18 @@ function createAccount() { let account = { firstName: document.getElementById('firstNameForm').value, lastName: document.getElementById('lastNameForm').value - } + }; + console.log(JSON.stringify(account)); let req = new XMLHttpRequest(); req.onload = function () { - let response = JSON.parse(req.response); - console.log(response); + console.log(req.responseText); } - req.open("POST", "http://localhost:5002/account/test"); + req.open("POST", "http://51.144.95.241:5002/account/createAccount"); req.send(JSON.stringify(account)); - return console.log(response.text); + console.log(req.responseText); } + diff --git a/text_gen/text_gen1.py b/text_gen/text_gen1.py index 39bb4b4..0816479 100644 --- a/text_gen/text_gen1.py +++ b/text_gen/text_gen1.py @@ -5,10 +5,10 @@ text_gen = Flask(__name__) -@text_gen.route('/text_gen/', methods=['GET']) +@text_gen.route('/text_gen/') def text_gen_method(): rand = (''.join(random.choice(string.ascii_lowercase) for i in range(3))) - return jsonify({"Random string":rand}) + return rand if __name__ == '__main__': text_gen.run(host='0.0.0.0', port=9017) diff --git a/text_gen/text_gen2.py b/text_gen/text_gen2.py index 1accd2a..6c38281 100644 --- a/text_gen/text_gen2.py +++ b/text_gen/text_gen2.py @@ -5,10 +5,10 @@ text_gen = Flask(__name__) -@text_gen.route('/text_gen/', methods=['GET']) +@text_gen.route('/text_gen/') def text_gen_method(): rand = (''.join(random.choice(string.ascii_uppercase) for i in range(2))) - return jsonify({"Random string":rand}) + return rand if __name__ == '__main__': text_gen.run(host='0.0.0.0', port=9017) From b8e64b8023c1a9ca38170cd6630c08badecbaca3 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 07:34:35 +0000 Subject: [PATCH 12/57] fixed url in javascript --- num_gen/num_gen1.PY | 0 server/src/main/resources/application.properties | 4 ++-- static_website/public/script.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 num_gen/num_gen1.PY diff --git a/num_gen/num_gen1.PY b/num_gen/num_gen1.PY new file mode 100644 index 0000000..e69de29 diff --git a/server/src/main/resources/application.properties b/server/src/main/resources/application.properties index ed4c313..ebdb869 100644 --- a/server/src/main/resources/application.properties +++ b/server/src/main/resources/application.properties @@ -4,6 +4,6 @@ spring.main.allow-bean-definition-overriding=true server.port=8084 url.getAll=http://account:5002/account/all -url.textGen=http://text_gen:9017/text_gen -url.numGen=http://num_gen:9018/num_gen +url.textGen=http://text_gen:9017/text_gen/ +url.numGen=http://num_gen:9018/num_gen/ url.prize=http://account:5002/account/createAccount diff --git a/static_website/public/script.js b/static_website/public/script.js index cdb1c3e..4356676 100644 --- a/static_website/public/script.js +++ b/static_website/public/script.js @@ -11,7 +11,7 @@ function createAccount() { console.log(req.responseText); } - req.open("POST", "http://51.144.95.241:5002/account/createAccount"); + req.open("POST", "http://51.144.95.241:8084/addAccount"); req.send(JSON.stringify(account)); console.log(req.responseText); } From c99d5ad30e5b8ef78cf02b9844af8d4d13d6387d Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 08:31:40 +0000 Subject: [PATCH 13/57] begin swarming --- docker-compose.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 9440b39..e6ea171 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -13,7 +13,6 @@ services: - target: 80 protocol: tcp published: 80 - container_name: nginx server: image: keepkarm/server:latest From bf9418281e89ef507257323f91c5464886277d9b Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 08:46:44 +0000 Subject: [PATCH 14/57] added Jenkinsfile --- Jenkinsfile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..fe8800e --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,20 @@ +pipeline{ + agent any + stages{ + stage('---build---'){ + steps{ + sh "docker-compose up --build -d" + } + } + stage('---push---'){ + steps{ + sh "docker-compose push" + } + } + stage('---deploy---'){ + steps{ + sh "docker stack deploy --compose-file docker-compose.yaml stackdemo" + } + } + } +} From c41ed7488f3013c0fb456d846be3e3e103c79691 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 09:02:27 +0000 Subject: [PATCH 15/57] added clean stage to Jenkinsfile --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index fe8800e..98e2c64 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,11 @@ pipeline{ agent any stages{ + stage('---clean---'){ + steps{ + sh "docker-compose down" + } + } stage('---build---'){ steps{ sh "docker-compose up --build -d" From 826f33d4e7042604916e945557eaac1c191b78f7 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 09:08:37 +0000 Subject: [PATCH 16/57] edit Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 98e2c64..c26cc16 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,7 @@ pipeline{ stages{ stage('---clean---'){ steps{ - sh "docker-compose down" + sh "docker-compose down --remove-orphans" } } stage('---build---'){ @@ -18,7 +18,7 @@ pipeline{ } stage('---deploy---'){ steps{ - sh "docker stack deploy --compose-file docker-compose.yaml stackdemo" + sh "docker stack deploy --compose-file docker-compose.yaml devops" } } } From a681cb041aa3a156cb7acfcac239f30a38e1783c Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 09:37:02 +0000 Subject: [PATCH 17/57] added jenkins mount --- docker-compose.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docker-compose.yaml b/docker-compose.yaml index e6ea171..359242f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -86,3 +86,10 @@ services: image: mongo ports: - "27017:27017" + + jenkins: + image: jenkins/jenkins:latest + ports: + - "8080:8080" + volumes: + - ${PWD}/jenkins:/var/jenkins_home From 546530f321e616ee128a899eab77c643e79744b7 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 10:28:09 +0000 Subject: [PATCH 18/57] jenkinsfile --- Jenkinsfile | 7 +------ docker-compose.yaml | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c26cc16..2bbe379 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,14 +1,9 @@ pipeline{ agent any stages{ - stage('---clean---'){ - steps{ - sh "docker-compose down --remove-orphans" - } - } stage('---build---'){ steps{ - sh "docker-compose up --build -d" + sh "docker-compose build" } } stage('---push---'){ diff --git a/docker-compose.yaml b/docker-compose.yaml index 359242f..7e4ef34 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,3 +1,4 @@ + version: '3.3' services: nginx: @@ -87,9 +88,3 @@ services: ports: - "27017:27017" - jenkins: - image: jenkins/jenkins:latest - ports: - - "8080:8080" - volumes: - - ${PWD}/jenkins:/var/jenkins_home From 0847c460bb10cc70139b6e0473712e7be2121893 Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 11:54:18 +0100 Subject: [PATCH 19/57] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2bbe379..ae70a30 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,12 +8,12 @@ pipeline{ } stage('---push---'){ steps{ - sh "docker-compose push" + sh "sudo docker-compose push" } } stage('---deploy---'){ steps{ - sh "docker stack deploy --compose-file docker-compose.yaml devops" + sh "sudo docker stack deploy --compose-file docker-compose.yaml devops" } } } From 4f4fa514e7d01ac671997888e9a6517032e16793 Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 11:57:11 +0100 Subject: [PATCH 20/57] Update Jenkinsfile --- Jenkinsfile | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ae70a30..511da75 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,14 +6,9 @@ pipeline{ sh "docker-compose build" } } - stage('---push---'){ - steps{ - sh "sudo docker-compose push" - } - } stage('---deploy---'){ steps{ - sh "sudo docker stack deploy --compose-file docker-compose.yaml devops" + sh "docker stack deploy --compose-file docker-compose.yaml devops" } } } From 255fa0e11547989a74b19fc8b314def62e06f3ba Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 12:01:03 +0100 Subject: [PATCH 21/57] Update docker-compose.yaml --- docker-compose.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 7e4ef34..6ee025e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -16,7 +16,7 @@ services: published: 80 server: - image: keepkarm/server:latest + image: ayshamarty/server:latest build: context: ./server dockerfile: Dockerfile @@ -26,7 +26,7 @@ services: - account client: - image: keepkarm/client:latest + image: ayshamarty/client:latest build: context: ./static_website dockerfile: Dockerfile @@ -34,7 +34,7 @@ services: - "8089:8089" notificationserver: - image: keepkarm/notify:latest + image: ayshamarty/notify:latest build: context: ./notification_server dockerfile: Dockerfile @@ -44,7 +44,7 @@ services: - account text_gen: - image: keepkarm/text_gen:v1 + image: ayshamarty/text_gen:v1 build: context: ./text_gen dockerfile: Dockerfile @@ -54,7 +54,7 @@ services: - server num_gen: - image: keepkarm/num_gen:v1 + image: ayshamarty/num_gen:v1 build: context: ./num_gen dockerfile: Dockerfile @@ -64,7 +64,7 @@ services: - server account: - image: keepkarm/account:v1 + image: ayshamarty/account:v1 build: context: ./account dockerfile: Dockerfile @@ -74,7 +74,7 @@ services: - db_connector db_connector: - image: keepkarm/db_connect:latest + image: ayshamarty/db_connect:latest build: context: ./db_connector dockerfile: Dockerfile From 0881aedd3f543daa880756fe7803259eb6db2fe8 Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 12:03:15 +0100 Subject: [PATCH 22/57] Update Jenkinsfile --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 511da75..2bbe379 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,6 +6,11 @@ pipeline{ sh "docker-compose build" } } + stage('---push---'){ + steps{ + sh "docker-compose push" + } + } stage('---deploy---'){ steps{ sh "docker stack deploy --compose-file docker-compose.yaml devops" From 33ac04a515b8c1416615d66f6a3ef28343683b5e Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 12:06:14 +0100 Subject: [PATCH 23/57] Update docker-compose.yaml --- docker-compose.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 6ee025e..7e4ef34 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -16,7 +16,7 @@ services: published: 80 server: - image: ayshamarty/server:latest + image: keepkarm/server:latest build: context: ./server dockerfile: Dockerfile @@ -26,7 +26,7 @@ services: - account client: - image: ayshamarty/client:latest + image: keepkarm/client:latest build: context: ./static_website dockerfile: Dockerfile @@ -34,7 +34,7 @@ services: - "8089:8089" notificationserver: - image: ayshamarty/notify:latest + image: keepkarm/notify:latest build: context: ./notification_server dockerfile: Dockerfile @@ -44,7 +44,7 @@ services: - account text_gen: - image: ayshamarty/text_gen:v1 + image: keepkarm/text_gen:v1 build: context: ./text_gen dockerfile: Dockerfile @@ -54,7 +54,7 @@ services: - server num_gen: - image: ayshamarty/num_gen:v1 + image: keepkarm/num_gen:v1 build: context: ./num_gen dockerfile: Dockerfile @@ -64,7 +64,7 @@ services: - server account: - image: ayshamarty/account:v1 + image: keepkarm/account:v1 build: context: ./account dockerfile: Dockerfile @@ -74,7 +74,7 @@ services: - db_connector db_connector: - image: ayshamarty/db_connect:latest + image: keepkarm/db_connect:latest build: context: ./db_connector dockerfile: Dockerfile From f2cb908ebf48ec326f237837f9e4c5e55475feea Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 12:09:54 +0100 Subject: [PATCH 24/57] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2bbe379..ef2689d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline{ } stage('---push---'){ steps{ - sh "docker-compose push" + sh "sudo docker push keepkarm/server:latest" } } stage('---deploy---'){ From 56d25254c55286352b4e55881bda5e329a970cac Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 12:10:34 +0100 Subject: [PATCH 25/57] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ef2689d..320274c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline{ } stage('---push---'){ steps{ - sh "sudo docker push keepkarm/server:latest" + sh "docker push keepkarm/server:latest" } } stage('---deploy---'){ From 778fc16feedea546328306f7f7363145456086fc Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 12:28:41 +0100 Subject: [PATCH 26/57] Update Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 320274c..20ff733 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,9 +7,9 @@ pipeline{ } } stage('---push---'){ - steps{ - sh "docker push keepkarm/server:latest" - } + withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'dockerhub', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { + sh 'docker login -u "$USERNAME" -p "$PASSWORD"' + cont.push() } stage('---deploy---'){ steps{ From 3d6d8a77b3f44fe27f1e7c8f89b1da9d05abad45 Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 12:30:00 +0100 Subject: [PATCH 27/57] Update Jenkinsfile --- Jenkinsfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 20ff733..38cb3cf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,9 +7,11 @@ pipeline{ } } stage('---push---'){ - withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'dockerhub', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { - sh 'docker login -u "$USERNAME" -p "$PASSWORD"' - cont.push() + steps{ + withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'dockerhub', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { + sh 'docker login -u "$USERNAME" -p "$PASSWORD"' + cont.push() + } } stage('---deploy---'){ steps{ From fd72aa8b8f6b184f73644bd2781cba5cf1a4d775 Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 12:30:43 +0100 Subject: [PATCH 28/57] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 38cb3cf..200081b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,3 +20,4 @@ pipeline{ } } } +} From 564637200544c1f3bd5809e0dec35565eb5bc32d Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 12:31:41 +0100 Subject: [PATCH 29/57] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 200081b..e0c5517 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline{ steps{ withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'dockerhub', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { sh 'docker login -u "$USERNAME" -p "$PASSWORD"' - cont.push() + sh 'docker-compose push' } } stage('---deploy---'){ From 0c310a1094c79f666c115af511c841aa38c1082c Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 12:33:28 +0100 Subject: [PATCH 30/57] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e0c5517..c39553b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,4 +20,4 @@ pipeline{ } } } -} + From d6eee465e516fc9af36bcee53a5753a3dfe2c9b4 Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 12:34:15 +0100 Subject: [PATCH 31/57] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index c39553b..9c6a8ea 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,4 +20,5 @@ pipeline{ } } } +} From c2373c2c1b9162f719ef09b08b7ba856a02b7231 Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 12:37:18 +0100 Subject: [PATCH 32/57] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9c6a8ea..e28d68f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline{ } stage('---push---'){ steps{ - withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'dockerhub', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { + withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'dockerhub', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) sh 'docker login -u "$USERNAME" -p "$PASSWORD"' sh 'docker-compose push' } @@ -20,5 +20,5 @@ pipeline{ } } } -} + From 2fc1473116e25d251fa2150128f5b9be7c15e06b Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 12:40:21 +0100 Subject: [PATCH 33/57] Update Jenkinsfile --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e28d68f..3c7240c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,9 +8,7 @@ pipeline{ } stage('---push---'){ steps{ - withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'dockerhub', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) - sh 'docker login -u "$USERNAME" -p "$PASSWORD"' - sh 'docker-compose push' + sh "sudo docker-compose push" } } stage('---deploy---'){ From faa6641b07a9a9e1f4cd6a04ff5b0e5fa96659e2 Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 12:42:05 +0100 Subject: [PATCH 34/57] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3c7240c..20f3885 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline{ } stage('---push---'){ steps{ - sh "sudo docker-compose push" + sh "docker-compose push" } } stage('---deploy---'){ From 3e38e3918cbc9a36b4555d4281abe2d36b35dffb Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 11:45:19 +0000 Subject: [PATCH 35/57] edited index to check if pipeline works --- static_website/public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static_website/public/index.html b/static_website/public/index.html index 242159a..18992fa 100644 --- a/static_website/public/index.html +++ b/static_website/public/index.html @@ -13,7 +13,7 @@

Landing Page



- + From 5a75d98061d5cf907e3624cfb015ab74a79870e7 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 11:51:25 +0000 Subject: [PATCH 36/57] reverted index - it does work --- static_website/public/index.html | 2 +- static_website/public/script.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/static_website/public/index.html b/static_website/public/index.html index 18992fa..242159a 100644 --- a/static_website/public/index.html +++ b/static_website/public/index.html @@ -13,7 +13,7 @@

Landing Page



- + diff --git a/static_website/public/script.js b/static_website/public/script.js index 4356676..a2ff365 100644 --- a/static_website/public/script.js +++ b/static_website/public/script.js @@ -3,7 +3,6 @@ function createAccount() { firstName: document.getElementById('firstNameForm').value, lastName: document.getElementById('lastNameForm').value }; - console.log(JSON.stringify(account)); let req = new XMLHttpRequest(); From 2d7d3306e33fd137d09a9784fd101867f2b3ace3 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 12:35:01 +0000 Subject: [PATCH 37/57] testing build args --- docker-compose.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 7e4ef34..6bc5fc8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -44,8 +44,10 @@ services: - account text_gen: - image: keepkarm/text_gen:v1 + image: keepkarm/text_gen:v2 build: + args: + FILE_VERSION: 2 context: ./text_gen dockerfile: Dockerfile ports: From 6ec112c7cd4b7d8df9ab498fbb3f67675a6f7b46 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 12:41:07 +0000 Subject: [PATCH 38/57] worked for text_gen so added build args for num and account --- docker-compose.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 6bc5fc8..b385eb7 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -56,8 +56,10 @@ services: - server num_gen: - image: keepkarm/num_gen:v1 + image: keepkarm/num_gen:v2 build: + args: + FILE_VERSION: 2 context: ./num_gen dockerfile: Dockerfile ports: @@ -66,8 +68,10 @@ services: - server account: - image: keepkarm/account:v1 + image: keepkarm/account:v2 build: + args: + FILE_VERSION: 2 context: ./account dockerfile: Dockerfile ports: From 78afbccca1f084db9e041b4f5f548717f026d85e Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 12:46:03 +0000 Subject: [PATCH 39/57] removed args from account to troubleshoot --- docker-compose.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index b385eb7..3c08223 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -68,10 +68,8 @@ services: - server account: - image: keepkarm/account:v2 + image: keepkarm/account:v1 build: - args: - FILE_VERSION: 2 context: ./account dockerfile: Dockerfile ports: From d991bec5daa89fc3f608f40bac1ad28c31d1f043 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 12:48:49 +0000 Subject: [PATCH 40/57] removed arg from num gen --- docker-compose.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 3c08223..e0684a0 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -58,8 +58,6 @@ services: num_gen: image: keepkarm/num_gen:v2 build: - args: - FILE_VERSION: 2 context: ./num_gen dockerfile: Dockerfile ports: From 2f1ccd03e9441f4ae3d31be2d8b3de81b98bbe36 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 12:51:03 +0000 Subject: [PATCH 41/57] added args to num gen --- docker-compose.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index e0684a0..41afb36 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -56,7 +56,7 @@ services: - server num_gen: - image: keepkarm/num_gen:v2 + image: keepkarm/num_gen:v1 build: context: ./num_gen dockerfile: Dockerfile @@ -66,8 +66,10 @@ services: - server account: - image: keepkarm/account:v1 + image: keepkarm/account:v2 build: + args: + FILE_VERSION: 2 context: ./account dockerfile: Dockerfile ports: From 642525cb81d370e844a22392ba8030dd69d663fb Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 12:54:01 +0000 Subject: [PATCH 42/57] num edited and build args added again --- docker-compose.yaml | 4 +++- num_gen/num_gen1.PY | 0 num_gen/num_gen2.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) delete mode 100644 num_gen/num_gen1.PY diff --git a/docker-compose.yaml b/docker-compose.yaml index 41afb36..b385eb7 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -56,8 +56,10 @@ services: - server num_gen: - image: keepkarm/num_gen:v1 + image: keepkarm/num_gen:v2 build: + args: + FILE_VERSION: 2 context: ./num_gen dockerfile: Dockerfile ports: diff --git a/num_gen/num_gen1.PY b/num_gen/num_gen1.PY deleted file mode 100644 index e69de29..0000000 diff --git a/num_gen/num_gen2.py b/num_gen/num_gen2.py index f07d254..1238f6c 100644 --- a/num_gen/num_gen2.py +++ b/num_gen/num_gen2.py @@ -5,7 +5,7 @@ @num_gen.route('/num_gen/') def num_gen_method(): rand = randint(10000000,99999999) - return (rand) + return str(rand) if __name__ == '__main__': num_gen.run(host='0.0.0.0', port=9018) From 8a86fdf90b609bc357ce32765403688a6dcced28 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 12:57:00 +0000 Subject: [PATCH 43/57] working and reverting num back to version 1 --- docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index b385eb7..5057347 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -56,10 +56,10 @@ services: - server num_gen: - image: keepkarm/num_gen:v2 + image: keepkarm/num_gen:v1 build: args: - FILE_VERSION: 2 + FILE_VERSION: 1 context: ./num_gen dockerfile: Dockerfile ports: From 4e9d6a17a3964d5e443b6a2136bead235e8e0bdb Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 13:15:41 +0000 Subject: [PATCH 44/57] change back --- docker-compose.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 5057347..8c2a62e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -44,10 +44,10 @@ services: - account text_gen: - image: keepkarm/text_gen:v2 + image: keepkarm/text_gen:v1 build: args: - FILE_VERSION: 2 + FILE_VERSION: 1 context: ./text_gen dockerfile: Dockerfile ports: @@ -56,10 +56,10 @@ services: - server num_gen: - image: keepkarm/num_gen:v1 + image: keepkarm/num_gen:v2 build: args: - FILE_VERSION: 1 + FILE_VERSION: 2 context: ./num_gen dockerfile: Dockerfile ports: @@ -68,10 +68,10 @@ services: - server account: - image: keepkarm/account:v2 + image: keepkarm/account:v1 build: args: - FILE_VERSION: 2 + FILE_VERSION: 1 context: ./account dockerfile: Dockerfile ports: From beb924982266a30976872bdf9b08470a9439d93e Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 19 Jul 2019 13:18:12 +0000 Subject: [PATCH 45/57] switch back --- docker-compose.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 8c2a62e..5057347 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -44,10 +44,10 @@ services: - account text_gen: - image: keepkarm/text_gen:v1 + image: keepkarm/text_gen:v2 build: args: - FILE_VERSION: 1 + FILE_VERSION: 2 context: ./text_gen dockerfile: Dockerfile ports: @@ -56,10 +56,10 @@ services: - server num_gen: - image: keepkarm/num_gen:v2 + image: keepkarm/num_gen:v1 build: args: - FILE_VERSION: 2 + FILE_VERSION: 1 context: ./num_gen dockerfile: Dockerfile ports: @@ -68,10 +68,10 @@ services: - server account: - image: keepkarm/account:v1 + image: keepkarm/account:v2 build: args: - FILE_VERSION: 1 + FILE_VERSION: 2 context: ./account dockerfile: Dockerfile ports: From 2502486b1f30a8f07bc4a0891bc17c3fc9f0e7ef Mon Sep 17 00:00:00 2001 From: Harry Buck Date: Fri, 19 Jul 2019 14:42:31 +0100 Subject: [PATCH 46/57] readme.md added --- README.md | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..0feb503 --- /dev/null +++ b/README.md @@ -0,0 +1,122 @@ +# Personal yoga application + +In fulfilment of the solo project assignment due Monday week 7 at QA consulting. + +## Index +[Brief](#brief) + * [Solution](#solution) + +[Architecture](#architecture) + * [Entity Relationship Diagrams](#erd) + * [Multi Tier Architechture Diagram](#mla) + +[Testing](#testing) + * [Report](#report) + + +[Deployment](#depl) + * [Technologies Used](#tech) + +[Front End Design](#FE) + +[Improvements for the Future](#improve) + +[Authors](#auth) + +[Acknowledgements](#ack) + + +## The Brief + +To create an OOP-based application with utilisation of supporting tools, methodologies and technologies that encapsulate all core modules covered during training. The application must manipulate two tables with full CRUD functionality. + + +### Solution + +I decided to create a personal yoga application that would allow the user to create poses and routines, as well as add and remove poses from each routine. + +The many to many relationship between poses and routines is working, where poses can be added and removed from routines. + + +## Architecture + +### Entity Relationship Diagrams +#### Initial plan +![Initial ERD](/Documentation/ERD_Initial_Plan.jpg) + +The initial plan for the ERD consisted of a lot more tables and entities than were produced in the final application. The tables are coloured based on how I had hoped to prioritise the features of the application, and therefore the order in which I would tackle them. Given the time constraints, I only managed to deliver two tables plus a join, as depicted below + +#### Delivered solution +![Final ERD](/Documentation/ERD_Final.jpg) + +As shown in this ERD, I ended up changing the focus of the initial tables. After building the first entity (poses), I concluded it made more sense to continue making a routine table first, encompassing a many-to-many relationship between the two. My reasoning was that it would make for a more interesting user experience to create routines from the poses, rather than arbitrarily add health benefits to each pose. + + +### Multi Tier Architecture Diagram +Please click on the diagram for a high resolution version: +![MTA](/Documentation/MTA.jpg) + +This is a very high-level architecture diagram to demonstrate the architecture of the application. It does not include getters and setters, test classes, or constants classes. + + + +## Testing + +JUnit, Mockito and Selenium tests have been used for automated testing, and SonarLint/SonarQube for static reporting and refactoring. + + +### Report + +[Link to Final Surefire Report](/Documentation/Surefire_Report.pdf) + +Test coverage for the backend is at 84%, there are as of yet no working Selenium tests but hope to get these running soon. +The SonarQube static report shows 9 code smells remaining, 0 bugs, 0 duplications and 0 vulnerabilities. + + +## Deployment + +The build, test and deployment process was automated using Jenkins, with a webhook to GitHub which was triggered with every push event + +This application can be deployed both locally and externally through a virtual machine. The constants.js file has commented out options to switch from an external to local IP address. + +![Deployment Pipeline](/Documentation/CI_pipeline.jpg) + +### Technologies Used + +* H2 Database Engine - Database +* Java - Logic +* Wildfly - Deployment +* Jenkins - CI Server +* Maven - Dependency Management +* Jacoco, EclEmma, Surefire - Test Reporting +* SonarQube - Static Testing +* [Git](https://github.com/ayshamarty/SoloProject.git) - VCS +* [Trello](https://trello.com/qasoloproject) - Project Tracking +* GCP - Live Environment + + +## Front End Design +### Wireframes +Poses +![Poses Wireframe](/Documentation/Poses_Wireframe.png) +Routines +![Routines Wireframe](/Documentation/Routines_Wireframe.png) +### Final Appearance + + +## Improvements for the Future + +Currently, IDs are required to update poses and routines, and to add or remove poses from routines. In my next sprint, I would like to create buttons in the front end which allow this functionality without the need for IDs, which would allow the object IDs to be hidden from the user. + +In later sprints, I would also like create a health-benefit entity which would have a many to many relationship with poses, so that users can create routines based on their focus for their practice. After this, I would add the capability to create different user accounts. At this point, I would remove the functionality for the user to add and remove poses themselves in the front end. These would instead be hard coded into the database, which the user could manipulate only for adding and removing them from their own routines. + + +## Authors + +Aysha Marty + + +## Acknowledgements + +* QA consulting and our fantastic instructors +* The rest of our wonderful cohort on the programme From ddfe593133376f98247603293554cfc90c6487ae Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 16:08:46 +0100 Subject: [PATCH 47/57] Update docker-compose.yaml --- docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 5057347..758c0d6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -44,10 +44,10 @@ services: - account text_gen: - image: keepkarm/text_gen:v2 + image: keepkarm/text_gen:v1 build: args: - FILE_VERSION: 2 + FILE_VERSION: 1 context: ./text_gen dockerfile: Dockerfile ports: From af4b6a51288b6e156576816b96c6057111efdf62 Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Fri, 19 Jul 2019 16:57:38 +0100 Subject: [PATCH 48/57] Update docker-compose.yaml --- docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 758c0d6..5057347 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -44,10 +44,10 @@ services: - account text_gen: - image: keepkarm/text_gen:v1 + image: keepkarm/text_gen:v2 build: args: - FILE_VERSION: 1 + FILE_VERSION: 2 context: ./text_gen dockerfile: Dockerfile ports: From 84992793a6945a313e820868993048bb7104c202 Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Sun, 21 Jul 2019 13:26:09 +0100 Subject: [PATCH 49/57] Update docker-compose.yaml --- docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 5057347..758c0d6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -44,10 +44,10 @@ services: - account text_gen: - image: keepkarm/text_gen:v2 + image: keepkarm/text_gen:v1 build: args: - FILE_VERSION: 2 + FILE_VERSION: 1 context: ./text_gen dockerfile: Dockerfile ports: From cbec65e67a5c13810174c46c642bc5bc56196559 Mon Sep 17 00:00:00 2001 From: ayshamarty Date: Sun, 21 Jul 2019 15:08:32 +0100 Subject: [PATCH 50/57] readme and installation scripts --- README.md | 235 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 157 insertions(+), 78 deletions(-) diff --git a/README.md b/README.md index 0feb503..18dee84 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,17 @@ -# Personal yoga application +# Little Anchorage Financial Bank: DevOps Project -In fulfilment of the solo project assignment due Monday week 7 at QA consulting. +In fulfilment of the group DevOps project assignment due Monday week 11 at QA consulting. ## Index [Brief](#brief) - * [Solution](#solution) [Architecture](#architecture) - * [Entity Relationship Diagrams](#erd) - * [Multi Tier Architechture Diagram](#mla) - -[Testing](#testing) - * [Report](#report) - - -[Deployment](#depl) - * [Technologies Used](#tech) -[Front End Design](#FE) +[Technologies Used](#tech) -[Improvements for the Future](#improve) +[Deployment](#depl) + * [Prerequisites and Installation Guide](#prereq) + * [CI Pipeline](#CI) [Authors](#auth) @@ -30,90 +22,177 @@ In fulfilment of the solo project assignment due Monday week 7 at QA consulting. To create an OOP-based application with utilisation of supporting tools, methodologies and technologies that encapsulate all core modules covered during training. The application must manipulate two tables with full CRUD functionality. - -### Solution - -I decided to create a personal yoga application that would allow the user to create poses and routines, as well as add and remove poses from each routine. - -The many to many relationship between poses and routines is working, where poses can be added and removed from routines. - ## Architecture - -### Entity Relationship Diagrams -#### Initial plan -![Initial ERD](/Documentation/ERD_Initial_Plan.jpg) - -The initial plan for the ERD consisted of a lot more tables and entities than were produced in the final application. The tables are coloured based on how I had hoped to prioritise the features of the application, and therefore the order in which I would tackle them. Given the time constraints, I only managed to deliver two tables plus a join, as depicted below - -#### Delivered solution -![Final ERD](/Documentation/ERD_Final.jpg) - -As shown in this ERD, I ended up changing the focus of the initial tables. After building the first entity (poses), I concluded it made more sense to continue making a routine table first, encompassing a many-to-many relationship between the two. My reasoning was that it would make for a more interesting user experience to create routines from the poses, rather than arbitrarily add health benefits to each pose. - - -### Multi Tier Architecture Diagram -Please click on the diagram for a high resolution version: -![MTA](/Documentation/MTA.jpg) - -This is a very high-level architecture diagram to demonstrate the architecture of the application. It does not include getters and setters, test classes, or constants classes. +#### Before +#### After - -## Testing - -JUnit, Mockito and Selenium tests have been used for automated testing, and SonarLint/SonarQube for static reporting and refactoring. - - -### Report - -[Link to Final Surefire Report](/Documentation/Surefire_Report.pdf) + +### Technologies Used -Test coverage for the backend is at 84%, there are as of yet no working Selenium tests but hope to get these running soon. -The SonarQube static report shows 9 code smells remaining, 0 bugs, 0 duplications and 0 vulnerabilities. +* Mongo - Database +* Node - creating the account generator which includes generating the prize +* Python - creating the number and text generator which generates an account number +* Jenkins - CI Server +* [Git](https://github.com/ayshamarty/SoloProject.git) - VCS +* [Trello](https://trello.com/b/yf6TuPx0/devops-project) - Project Tracking +* Azure - Live Environment +* Docker-Compose - builds the images used to create our containers +* [DockerHub](https://cloud.docker.com/u/keepkarm/repository/list) - registry for storing and updating images used for deployment +* Docker Swarm ## Deployment -The build, test and deployment process was automated using Jenkins, with a webhook to GitHub which was triggered with every push event + +### Prerequisites +* An Azure virtual machine with Jenkins, Docker and Docker-Compose installed +* At least one other Azure virtual machine with Docker installed +* Access to a Dockerhub registry -This application can be deployed both locally and externally through a virtual machine. The constants.js file has commented out options to switch from an external to local IP address. +#### Installing Jenkins, Docker and Docker Compose, and setting up the swarm -![Deployment Pipeline](/Documentation/CI_pipeline.jpg) - -### Technologies Used +##### Setting the project -* H2 Database Engine - Database -* Java - Logic -* Wildfly - Deployment -* Jenkins - CI Server -* Maven - Dependency Management -* Jacoco, EclEmma, Surefire - Test Reporting -* SonarQube - Static Testing -* [Git](https://github.com/ayshamarty/SoloProject.git) - VCS -* [Trello](https://trello.com/qasoloproject) - Project Tracking -* GCP - Live Environment +1. Create a new resource group +

+**az group create –name devops -l uksouth** +

- -## Front End Design -### Wireframes -Poses -![Poses Wireframe](/Documentation/Poses_Wireframe.png) -Routines -![Routines Wireframe](/Documentation/Routines_Wireframe.png) -### Final Appearance +2. Create a new virtual machine +

+**az vm create -g devops -n ManagerNode --image UbuntuLTS -l uksouth** +*repeat this command at least once to create your worker nodes, renaming the machines in the -n tag (eg -n Worker1)* +

- -## Improvements for the Future +3. Clone down the project within your ManagerNode +

+**git clone https://github.com/kryan1622/LAFB.git** +

-Currently, IDs are required to update poses and routines, and to add or remove poses from routines. In my next sprint, I would like to create buttons in the front end which allow this functionality without the need for IDs, which would allow the object IDs to be hidden from the user. +4. Install docker and jenkins with with the included scripts and follow the instructions +

+**sh ~/LAFB/installation/docker.sh** +*remember to copy this script and run it on your worker nodes* + +**sh ~/LAFB/installation/jenkins.sh** +

+ +##### Building the images + +1. Build docker images +

+**docker-compose build** +

+ +2. Push docker images to the desired dockerhub account by first logging onto dockerhub within the virtual machine +

+**docker login** +*Enter username and password when requested* + +**docker-compose push** +

+ +##### Setting up the swarm + +1. Initialise your swarm in the manager node +

+**docker swarm init** +*this will return a command with a unique token which you can run in any number of other virtual machines to set them up as your worker nodes* +

+ +2. Deploy containers with the built images in docker swarm +

+**docker stack deploy --compose-file docker-compose.yaml devops** +

+ +##### Setting up Continuous Integration with Jenkins + +q. As the Jenkins user, login to a dockerhub account that has access to the registry: +

+**sudo su Jenkins** +**docker login** +*Enter username and password when requested* +

+ +2. Expose port 8080 to access Jenkins externally using the command: +

+**az vm open-port -g devops -n devopsproject --port 8080 --priority 900** +

+ +3. Access Jenkins site using the public ip address of the virtual machine being used with the addition of :8080 at the end. For example: + +4. Get password for initial screen in Jenkins using the command: +

+**sudo cat /var/lib/jenkins/secrets/initialAdminPassword** +

+ +5. On the customize Jenkins page select the option to Install suggested plugins, and create your username and password. + +6. Set up the pipeline +..1. Create Jenkins pipeline by selecting the new item option. Then name the job and select the pipeline option. + +..2. Then in the general section select the GitHub project option and copy in the URL below. +https://github.com/kryan1622/LAFB.git + +..3. Create webhook by selecting the trigger build remotely option in the Build Triggers section and type in: +DEVOPS + +..4. In the pipeline section, select the "Pipeline Script from SCM" option in "Definition". elect Git in the dropdown menu of SCM and copy in the URL used above into Repository URL. + +To complete the webhook go into the settings option within the GitHub repository. Then select the webhook tab and select + +http://51.144.95.241:8080/job/jobname/build + +Then in the payload URL http://username:password@PublicIP:8080/job/jobname/build?token=TOKEN + + + +### CI pipeline +![CI Pipeline](/documentation/CIpipeline.png) + +#### Overview +The above diagram shows the flow of the continuous integration pipeline. +When a developer makes a change to the application in the source code and pushed to GitHub, the webhook is triggered and the Jenkins pipeline will automatically run. +The pipeline runs the following stages: +##### Build + * Goes through the docker-compose.yaml and rebuilds any images that have been changed +##### Push + * Pushes changed images to dockerhub +##### Deploy + * Updates changed containers in the stack without redeploying the entire application or affecting the user experience + +#### Switching Implementations +The client asked for three different unique implementations to be included, these were for the prize generator, number generator and account generator. We have provided these and they can be seemlessly switched out for each other. +The images used are as follows: +##### prize generator +keepkarm/account:v1 + * on creating an account, generates a prize of £50 or £0 with a 25% probability of winning +keepkarm/account:v2 + * on creating an account, generates a prize of £100 or £0 with a 25% probability of winning +##### text generator +keepkarm/text_gen:v1 + * generates a random string of three lowercase letters +keepkarm/text_gen:v2 + * generates a random string of two uppercase letters +##### number generator +keepkarm/num_gen:v1 + * generates a random six digit number +keepkarm/num_gen:v2 + * generates a random eight digit number + +If the bank's developers want to switch out any of these implementations for the other, all they need to do is edit the docker-compose.yaml file and push it up to git hub. They can swap the implementations for any of the services by changing both version number in the image name, and the number in the build args option. It is crucial to note that that **both numbers must match**. +When the new docker-compose.yaml is pushed to GitHub -In later sprints, I would also like create a health-benefit entity which would have a many to many relationship with poses, so that users can create routines based on their focus for their practice. After this, I would add the capability to create different user accounts. At this point, I would remove the functionality for the user to add and remove poses themselves in the front end. These would instead be hard coded into the database, which the user could manipulate only for adding and removing them from their own routines. +### Improvements for the Future +Using a local registry would be helpful if deploying this application continuously. In cases of internet connection failures or dockerhub going down (which is not unlikely), images can still be easily accessed. +We suggest using a registry container to improve redundancy. ## Authors -Aysha Marty +Aysha Marty and Krystal Ryan ## Acknowledgements From 6b4d729774931bdd9c377eb87b51fe827468e04e Mon Sep 17 00:00:00 2001 From: ayshamarty Date: Sun, 21 Jul 2019 15:09:08 +0100 Subject: [PATCH 51/57] installation scripts --- installation/docker.sh | 13 +++++++++++++ installation/jenkins.sh | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 installation/docker.sh create mode 100644 installation/jenkins.sh diff --git a/installation/docker.sh b/installation/docker.sh new file mode 100644 index 0000000..7c381e7 --- /dev/null +++ b/installation/docker.sh @@ -0,0 +1,13 @@ +#! /bin/bash + +user=$(whoami) + +curl https://get.docker.com | sudo bash +sudo usermod -aG docker $user +sudo systemctl docker start +sudo systemctl docker enable + +sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose +sudo chmod +x /usr/local/bin/docker-compose + +echo "Please restart your terminal" \ No newline at end of file diff --git a/installation/jenkins.sh b/installation/jenkins.sh new file mode 100644 index 0000000..29e50c8 --- /dev/null +++ b/installation/jenkins.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +sudo apt update +sudo apt install -y openjdk-8-jdk +sudo apt install -y maven + +wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add - + +sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' + +sudo apt update +sudo apt install -y jenkins + +sudo usermod -aG docker Jenkins + +sudo chmod 777 /var/lib/jenkins/secrets/initialAdminPassword +sudo cat /var/lib/jenkins/secrets/initialAdminPassword + +echo "Please restart your terminal" \ No newline at end of file From 351e3bd001d91a0585ae77adfb9f4e03b26f3181 Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Sun, 21 Jul 2019 15:15:33 +0100 Subject: [PATCH 52/57] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 18dee84..a8c9b0e 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ To create an OOP-based application with utilisation of supporting tools, methodo 2. Create a new virtual machine

**az vm create -g devops -n ManagerNode --image UbuntuLTS -l uksouth** + *repeat this command at least once to create your worker nodes, renaming the machines in the -n tag (eg -n Worker1)*

From 304c9ab8cbf6fea6dabb806cdd06b7ab8f417967 Mon Sep 17 00:00:00 2001 From: kryan1622 <50928440+kryan1622@users.noreply.github.com> Date: Sun, 21 Jul 2019 15:21:16 +0100 Subject: [PATCH 53/57] Update README.md --- README.md | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a8c9b0e..3b4a74c 100644 --- a/README.md +++ b/README.md @@ -57,11 +57,13 @@ To create an OOP-based application with utilisation of supporting tools, methodo 1. Create a new resource group

+ **az group create –name devops -l uksouth**

2. Create a new virtual machine

+ **az vm create -g devops -n ManagerNode --image UbuntuLTS -l uksouth** *repeat this command at least once to create your worker nodes, renaming the machines in the -n tag (eg -n Worker1)* @@ -69,12 +71,15 @@ To create an OOP-based application with utilisation of supporting tools, methodo 3. Clone down the project within your ManagerNode

+ **git clone https://github.com/kryan1622/LAFB.git**

4. Install docker and jenkins with with the included scripts and follow the instructions

+ **sh ~/LAFB/installation/docker.sh** + *remember to copy this script and run it on your worker nodes* **sh ~/LAFB/installation/jenkins.sh** @@ -84,12 +89,15 @@ To create an OOP-based application with utilisation of supporting tools, methodo 1. Build docker images

+ **docker-compose build**

2. Push docker images to the desired dockerhub account by first logging onto dockerhub within the virtual machine

+ **docker login** + *Enter username and password when requested* **docker-compose push** @@ -99,19 +107,23 @@ To create an OOP-based application with utilisation of supporting tools, methodo 1. Initialise your swarm in the manager node

+ **docker swarm init** + *this will return a command with a unique token which you can run in any number of other virtual machines to set them up as your worker nodes*

2. Deploy containers with the built images in docker swarm

+ **docker stack deploy --compose-file docker-compose.yaml devops**

##### Setting up Continuous Integration with Jenkins -q. As the Jenkins user, login to a dockerhub account that has access to the registry: +1. As the Jenkins user, login to a dockerhub account that has access to the registry:

+ **sudo su Jenkins** **docker login** *Enter username and password when requested* @@ -119,6 +131,7 @@ q. As the Jenkins user, login to a dockerhub account that has access to the regi 2. Expose port 8080 to access Jenkins externally using the command:

+ **az vm open-port -g devops -n devopsproject --port 8080 --priority 900**

@@ -126,21 +139,22 @@ q. As the Jenkins user, login to a dockerhub account that has access to the regi 4. Get password for initial screen in Jenkins using the command:

+ **sudo cat /var/lib/jenkins/secrets/initialAdminPassword**

5. On the customize Jenkins page select the option to Install suggested plugins, and create your username and password. 6. Set up the pipeline -..1. Create Jenkins pipeline by selecting the new item option. Then name the job and select the pipeline option. + 1. Create Jenkins pipeline by selecting the new item option. Then name the job and select the pipeline option. -..2. Then in the general section select the GitHub project option and copy in the URL below. + 2. Then in the general section select the GitHub project option and copy in the URL below. https://github.com/kryan1622/LAFB.git -..3. Create webhook by selecting the trigger build remotely option in the Build Triggers section and type in: + 3. Create webhook by selecting the trigger build remotely option in the Build Triggers section and type in: DEVOPS -..4. In the pipeline section, select the "Pipeline Script from SCM" option in "Definition". elect Git in the dropdown menu of SCM and copy in the URL used above into Repository URL. + 4. In the pipeline section, select the "Pipeline Script from SCM" option in "Definition". elect Git in the dropdown menu of SCM and copy in the URL used above into Repository URL. To complete the webhook go into the settings option within the GitHub repository. Then select the webhook tab and select From 0dcb59bf164efa9cf293e4b3425726dce6946daf Mon Sep 17 00:00:00 2001 From: ayshamarty <50907372+ayshamarty@users.noreply.github.com> Date: Sun, 21 Jul 2019 15:22:49 +0100 Subject: [PATCH 54/57] Update README.md --- README.md | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 18dee84..3b4a74c 100644 --- a/README.md +++ b/README.md @@ -57,23 +57,29 @@ To create an OOP-based application with utilisation of supporting tools, methodo 1. Create a new resource group

+ **az group create –name devops -l uksouth**

2. Create a new virtual machine

+ **az vm create -g devops -n ManagerNode --image UbuntuLTS -l uksouth** + *repeat this command at least once to create your worker nodes, renaming the machines in the -n tag (eg -n Worker1)*

3. Clone down the project within your ManagerNode

+ **git clone https://github.com/kryan1622/LAFB.git**

4. Install docker and jenkins with with the included scripts and follow the instructions

+ **sh ~/LAFB/installation/docker.sh** + *remember to copy this script and run it on your worker nodes* **sh ~/LAFB/installation/jenkins.sh** @@ -83,12 +89,15 @@ To create an OOP-based application with utilisation of supporting tools, methodo 1. Build docker images

+ **docker-compose build**

2. Push docker images to the desired dockerhub account by first logging onto dockerhub within the virtual machine

+ **docker login** + *Enter username and password when requested* **docker-compose push** @@ -98,19 +107,23 @@ To create an OOP-based application with utilisation of supporting tools, methodo 1. Initialise your swarm in the manager node

+ **docker swarm init** + *this will return a command with a unique token which you can run in any number of other virtual machines to set them up as your worker nodes*

2. Deploy containers with the built images in docker swarm

+ **docker stack deploy --compose-file docker-compose.yaml devops**

##### Setting up Continuous Integration with Jenkins -q. As the Jenkins user, login to a dockerhub account that has access to the registry: +1. As the Jenkins user, login to a dockerhub account that has access to the registry:

+ **sudo su Jenkins** **docker login** *Enter username and password when requested* @@ -118,6 +131,7 @@ q. As the Jenkins user, login to a dockerhub account that has access to the regi 2. Expose port 8080 to access Jenkins externally using the command:

+ **az vm open-port -g devops -n devopsproject --port 8080 --priority 900**

@@ -125,21 +139,22 @@ q. As the Jenkins user, login to a dockerhub account that has access to the regi 4. Get password for initial screen in Jenkins using the command:

+ **sudo cat /var/lib/jenkins/secrets/initialAdminPassword**

5. On the customize Jenkins page select the option to Install suggested plugins, and create your username and password. 6. Set up the pipeline -..1. Create Jenkins pipeline by selecting the new item option. Then name the job and select the pipeline option. + 1. Create Jenkins pipeline by selecting the new item option. Then name the job and select the pipeline option. -..2. Then in the general section select the GitHub project option and copy in the URL below. + 2. Then in the general section select the GitHub project option and copy in the URL below. https://github.com/kryan1622/LAFB.git -..3. Create webhook by selecting the trigger build remotely option in the Build Triggers section and type in: + 3. Create webhook by selecting the trigger build remotely option in the Build Triggers section and type in: DEVOPS -..4. In the pipeline section, select the "Pipeline Script from SCM" option in "Definition". elect Git in the dropdown menu of SCM and copy in the URL used above into Repository URL. + 4. In the pipeline section, select the "Pipeline Script from SCM" option in "Definition". elect Git in the dropdown menu of SCM and copy in the URL used above into Repository URL. To complete the webhook go into the settings option within the GitHub repository. Then select the webhook tab and select From 9ab49a3b3e156616d49f01e8cc6c7099f936682a Mon Sep 17 00:00:00 2001 From: ayshamarty <50907372+ayshamarty@users.noreply.github.com> Date: Sun, 21 Jul 2019 15:42:13 +0100 Subject: [PATCH 55/57] Update README.md --- README.md | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 3b4a74c..3ce0756 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ In fulfilment of the group DevOps project assignment due Monday week 11 at QA co ## The Brief -To create an OOP-based application with utilisation of supporting tools, methodologies and technologies that encapsulate all core modules covered during training. The application must manipulate two tables with full CRUD functionality. + ## Architecture @@ -51,31 +51,37 @@ To create an OOP-based application with utilisation of supporting tools, methodo * At least one other Azure virtual machine with Docker installed * Access to a Dockerhub registry -#### Installing Jenkins, Docker and Docker Compose, and setting up the swarm +### Installing Jenkins, Docker and Docker Compose, and setting up the swarm + +#### Setting up the project: -##### Setting the project +1. Create a new resource group: -1. Create a new resource group

-**az group create –name devops -l uksouth** + az group create –name devops -l uksouth

-2. Create a new virtual machine +2. Create a new virtual machine: +

-**az vm create -g devops -n ManagerNode --image UbuntuLTS -l uksouth** + az vm create -g devops -n ManagerNode --image UbuntuLTS -l uksouth *repeat this command at least once to create your worker nodes, renaming the machines in the -n tag (eg -n Worker1)* +

3. Clone down the project within your ManagerNode +

**git clone https://github.com/kryan1622/LAFB.git** +

4. Install docker and jenkins with with the included scripts and follow the instructions +

**sh ~/LAFB/installation/docker.sh** @@ -83,14 +89,17 @@ To create an OOP-based application with utilisation of supporting tools, methodo *remember to copy this script and run it on your worker nodes* **sh ~/LAFB/installation/jenkins.sh** +

-##### Building the images +#### Building the images 1. Build docker images +

**docker-compose build** +

2. Push docker images to the desired dockerhub account by first logging onto dockerhub within the virtual machine @@ -101,35 +110,43 @@ To create an OOP-based application with utilisation of supporting tools, methodo *Enter username and password when requested* **docker-compose push** +

-##### Setting up the swarm +#### Setting up the swarm 1. Initialise your swarm in the manager node +

**docker swarm init** *this will return a command with a unique token which you can run in any number of other virtual machines to set them up as your worker nodes* +

2. Deploy containers with the built images in docker swarm +

**docker stack deploy --compose-file docker-compose.yaml devops** +

-##### Setting up Continuous Integration with Jenkins +#### Setting up Continuous Integration with Jenkins 1. As the Jenkins user, login to a dockerhub account that has access to the registry: +

**sudo su Jenkins** **docker login** *Enter username and password when requested* +

2. Expose port 8080 to access Jenkins externally using the command: +

**az vm open-port -g devops -n devopsproject --port 8080 --priority 900** @@ -138,9 +155,11 @@ To create an OOP-based application with utilisation of supporting tools, methodo 3. Access Jenkins site using the public ip address of the virtual machine being used with the addition of :8080 at the end. For example: 4. Get password for initial screen in Jenkins using the command: -

+ +

**sudo cat /var/lib/jenkins/secrets/initialAdminPassword** +

5. On the customize Jenkins page select the option to Install suggested plugins, and create your username and password. From a793e15d5be4ad0b7cf5aa9558212c90c82a79d4 Mon Sep 17 00:00:00 2001 From: ayshamarty <50907372+ayshamarty@users.noreply.github.com> Date: Sun, 21 Jul 2019 15:43:48 +0100 Subject: [PATCH 56/57] Update README.md --- README.md | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 3ce0756..ac2218b 100644 --- a/README.md +++ b/README.md @@ -18,18 +18,18 @@ In fulfilment of the group DevOps project assignment due Monday week 11 at QA co [Acknowledgements](#ack) -## The Brief +# The Brief -## Architecture -#### Before +# Architecture +### Before -#### After +### After -### Technologies Used +## Technologies Used * Mongo - Database * Node - creating the account generator which includes generating the prize @@ -43,17 +43,17 @@ In fulfilment of the group DevOps project assignment due Monday week 11 at QA co * Docker Swarm -## Deployment +# Deployment -### Prerequisites +## Prerequisites * An Azure virtual machine with Jenkins, Docker and Docker-Compose installed * At least one other Azure virtual machine with Docker installed * Access to a Dockerhub registry -### Installing Jenkins, Docker and Docker Compose, and setting up the swarm +## Installing Jenkins, Docker and Docker Compose, and setting up the swarm -#### Setting up the project: +### Setting up the project: 1. Create a new resource group: @@ -76,7 +76,7 @@ In fulfilment of the group DevOps project assignment due Monday week 11 at QA co

-**git clone https://github.com/kryan1622/LAFB.git** + git clone https://github.com/kryan1622/LAFB.git

@@ -84,21 +84,21 @@ In fulfilment of the group DevOps project assignment due Monday week 11 at QA co

-**sh ~/LAFB/installation/docker.sh** + sh ~/LAFB/installation/docker.sh *remember to copy this script and run it on your worker nodes* - -**sh ~/LAFB/installation/jenkins.sh** + + *sh ~/LAFB/installation/jenkins.sh

-#### Building the images +### Building the images 1. Build docker images

-**docker-compose build** + docker-compose build

@@ -113,7 +113,7 @@ In fulfilment of the group DevOps project assignment due Monday week 11 at QA co

-#### Setting up the swarm +### Setting up the swarm 1. Initialise your swarm in the manager node @@ -133,7 +133,7 @@ In fulfilment of the group DevOps project assignment due Monday week 11 at QA co

-#### Setting up Continuous Integration with Jenkins +### Setting up Continuous Integration with Jenkins 1. As the Jenkins user, login to a dockerhub account that has access to the registry: @@ -183,34 +183,34 @@ Then in the payload URL http://username:password@PublicIP:8080/job/jobname/build -### CI pipeline +## CI pipeline ![CI Pipeline](/documentation/CIpipeline.png) -#### Overview +### Overview The above diagram shows the flow of the continuous integration pipeline. When a developer makes a change to the application in the source code and pushed to GitHub, the webhook is triggered and the Jenkins pipeline will automatically run. The pipeline runs the following stages: -##### Build +#### Build * Goes through the docker-compose.yaml and rebuilds any images that have been changed -##### Push +#### Push * Pushes changed images to dockerhub -##### Deploy +#### Deploy * Updates changed containers in the stack without redeploying the entire application or affecting the user experience -#### Switching Implementations +### Switching Implementations The client asked for three different unique implementations to be included, these were for the prize generator, number generator and account generator. We have provided these and they can be seemlessly switched out for each other. The images used are as follows: -##### prize generator +#### prize generator keepkarm/account:v1 * on creating an account, generates a prize of £50 or £0 with a 25% probability of winning keepkarm/account:v2 * on creating an account, generates a prize of £100 or £0 with a 25% probability of winning -##### text generator +#### text generator keepkarm/text_gen:v1 * generates a random string of three lowercase letters keepkarm/text_gen:v2 * generates a random string of two uppercase letters -##### number generator +#### number generator keepkarm/num_gen:v1 * generates a random six digit number keepkarm/num_gen:v2 @@ -219,7 +219,7 @@ keepkarm/num_gen:v2 If the bank's developers want to switch out any of these implementations for the other, all they need to do is edit the docker-compose.yaml file and push it up to git hub. They can swap the implementations for any of the services by changing both version number in the image name, and the number in the build args option. It is crucial to note that that **both numbers must match**. When the new docker-compose.yaml is pushed to GitHub -### Improvements for the Future +## Improvements for the Future Using a local registry would be helpful if deploying this application continuously. In cases of internet connection failures or dockerhub going down (which is not unlikely), images can still be easily accessed. We suggest using a registry container to improve redundancy. From 344f6674ba8860c63818bffcce06a287f7fffc87 Mon Sep 17 00:00:00 2001 From: ayshamarty <50907372+ayshamarty@users.noreply.github.com> Date: Sun, 21 Jul 2019 15:46:36 +0100 Subject: [PATCH 57/57] Update README.md --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index ac2218b..e4781dc 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ In fulfilment of the group DevOps project assignment due Monday week 11 at QA co *remember to copy this script and run it on your worker nodes* - *sh ~/LAFB/installation/jenkins.sh + sh ~/LAFB/installation/jenkins.sh

@@ -105,11 +105,11 @@ In fulfilment of the group DevOps project assignment due Monday week 11 at QA co 2. Push docker images to the desired dockerhub account by first logging onto dockerhub within the virtual machine

-**docker login** + docker login *Enter username and password when requested* -**docker-compose push** + docker-compose push

@@ -119,7 +119,7 @@ In fulfilment of the group DevOps project assignment due Monday week 11 at QA co

-**docker swarm init** + docker swarm init *this will return a command with a unique token which you can run in any number of other virtual machines to set them up as your worker nodes* @@ -129,7 +129,7 @@ In fulfilment of the group DevOps project assignment due Monday week 11 at QA co

-**docker stack deploy --compose-file docker-compose.yaml devops** + docker stack deploy --compose-file docker-compose.yaml devops

@@ -139,8 +139,8 @@ In fulfilment of the group DevOps project assignment due Monday week 11 at QA co

-**sudo su Jenkins** -**docker login** + sudo su jenkins + docker login *Enter username and password when requested*

@@ -149,7 +149,7 @@ In fulfilment of the group DevOps project assignment due Monday week 11 at QA co

-**az vm open-port -g devops -n devopsproject --port 8080 --priority 900** + az vm open-port -g devops -n devopsproject --port 8080 --priority 900

3. Access Jenkins site using the public ip address of the virtual machine being used with the addition of :8080 at the end. For example: @@ -158,7 +158,7 @@ In fulfilment of the group DevOps project assignment due Monday week 11 at QA co

-**sudo cat /var/lib/jenkins/secrets/initialAdminPassword** + sudo cat /var/lib/jenkins/secrets/initialAdminPassword

@@ -191,11 +191,11 @@ The above diagram shows the flow of the continuous integration pipeline. When a developer makes a change to the application in the source code and pushed to GitHub, the webhook is triggered and the Jenkins pipeline will automatically run. The pipeline runs the following stages: #### Build - * Goes through the docker-compose.yaml and rebuilds any images that have been changed +*Goes through the docker-compose.yaml and rebuilds any images that have been changed* #### Push - * Pushes changed images to dockerhub +*Pushes changed images to dockerhub* #### Deploy - * Updates changed containers in the stack without redeploying the entire application or affecting the user experience +*Updates changed containers in the stack without redeploying the entire application or affecting the user experience* ### Switching Implementations The client asked for three different unique implementations to be included, these were for the prize generator, number generator and account generator. We have provided these and they can be seemlessly switched out for each other.