diff --git a/db_connector/Dockerfile b/db_connector/Dockerfile new file mode 100644 index 0000000..aa341f2 --- /dev/null +++ b/db_connector/Dockerfile @@ -0,0 +1,5 @@ +FROM node:10 +COPY . . +RUN npm install +EXPOSE 5001 +ENTRYPOINT ["node", "server.js"] diff --git a/db_connector/config/keys.js b/db_connector/config/keys.js index e61b6ed..c333c2a 100755 --- a/db_connector/config/keys.js +++ b/db_connector/config/keys.js @@ -1,4 +1,3 @@ module.exports = { - mongoURI: "mongodb://lafb:lafb123@ds165632.mlab.com:63835/accounts" + mongoURI: "mongodb://mongo:27017/account" }; - diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..ae8f8c3 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,38 @@ +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: + - "27017:27017" 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/num_gen/Dockerfile b/num_gen/Dockerfile new file mode 100644 index 0000000..d19a2de --- /dev/null +++ b/num_gen/Dockerfile @@ -0,0 +1,6 @@ +FROM python +ARG FILE_VERSION=1 +COPY . . +COPY num_gen${FILE_VERSION}.py app.py +RUN pip install flask +ENTRYPOINT ["python", "app.py"] diff --git a/num_gen/num_gen1.py b/num_gen/num_gen1.py new file mode 100644 index 0000000..6c23b98 --- /dev/null +++ b/num_gen/num_gen1.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=9018) diff --git a/num_gen/num_gen2.py b/num_gen/num_gen2.py new file mode 100644 index 0000000..f885bed --- /dev/null +++ b/num_gen/num_gen2.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(10000000,99999999) + return jsonify({"Random Number":rand}) + +if __name__ == '__main__': + num_gen.run(host='0.0.0.0', port=9018) diff --git a/prize_gen/Dockerfile b/prize_gen/Dockerfile new file mode 100644 index 0000000..40a7f9a --- /dev/null +++ b/prize_gen/Dockerfile @@ -0,0 +1,7 @@ +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", "app.py"] diff --git a/prize_gen/prize_gen1.py b/prize_gen/prize_gen1.py new file mode 100644 index 0000000..143a618 --- /dev/null +++ b/prize_gen/prize_gen1.py @@ -0,0 +1,20 @@ +from flask import Flask, jsonify, make_response +import random +import requests +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: + request.get('http://localhost:9000/notify') + 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/prize_gen/prize_gen2.py b/prize_gen/prize_gen2.py new file mode 100644 index 0000000..eeb849a --- /dev/null +++ b/prize_gen/prize_gen2.py @@ -0,0 +1,20 @@ +from flask import Flask, jsonify, make_response +import random +import requests +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: + request.get('http://localhost:9000/notify') + 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..d93626e --- /dev/null +++ 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"] 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"] diff --git a/text_gen/Dockerfile b/text_gen/Dockerfile new file mode 100644 index 0000000..da32481 --- /dev/null +++ b/text_gen/Dockerfile @@ -0,0 +1,6 @@ +FROM python +ARG FILE_VERSION=1 +COPY . . +COPY text_gen${FILE_VERSION}.py app.py +RUN pip install flask +ENTRYPOINT ["python", "app.py"] diff --git a/text_gen/text_gen1.py b/text_gen/text_gen1.py new file mode 100644 index 0000000..39bb4b4 --- /dev/null +++ b/text_gen/text_gen1.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_lowercase) for i in range(3))) + return jsonify({"Random string":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 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)