diff --git a/payments/Dockerfile b/payments/Dockerfile index 0b6513a..b5e3b35 100644 --- a/payments/Dockerfile +++ b/payments/Dockerfile @@ -1,8 +1,10 @@ FROM 21dotco/two1:base MAINTAINER 21.co -ADD . /usr/src/app - RUN apk add --no-cache linux-headers -RUN pip3 install -r /usr/src/app/requirements.txt -CMD sh -c "python3 /usr/src/app/utils/login.py && sleep 2 && python3 /usr/src/app/server.py" \ No newline at end of file + +WORKDIR /usr/src/app +COPY . ./ + +RUN pip3 install -e . -U +CMD sh -c "python3 utils/login.py && sleep 2 && python3 server.py" diff --git a/payments/requirements.txt b/payments/requirements.txt deleted file mode 100644 index 470ef19..0000000 --- a/payments/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -Flask==0.10.1 -gunicorn==19.4.5 diff --git a/payments/setup.py b/payments/setup.py new file mode 100644 index 0000000..bb35854 --- /dev/null +++ b/payments/setup.py @@ -0,0 +1,11 @@ +import setuptools + +setuptools.setup( + name='payments', + version='0.0.1', + packages=setuptools.find_packages(), + install_requires=[ + 'Flask==0.10.1', + 'gunicorn==19.4.5', + ], +) diff --git a/router/Dockerfile b/router/Dockerfile index fb56e40..244ba40 100644 --- a/router/Dockerfile +++ b/router/Dockerfile @@ -1,9 +1,11 @@ FROM alpine:3.3 +MAINTAINER 21.co RUN apk upgrade -U --available RUN apk add --no-cache nginx curl RUN rm /etc/nginx/nginx.conf RUN rm /etc/nginx/nginx.conf.default + COPY files/nginx.conf /etc/nginx/nginx.conf -CMD nginx -g "daemon off;" \ No newline at end of file +CMD nginx -g "daemon off;" diff --git a/router/files/nginx.conf b/router/files/nginx.conf index b646da3..fdfe8c2 100644 --- a/router/files/nginx.conf +++ b/router/files/nginx.conf @@ -46,4 +46,4 @@ http { ## include /etc/nginx/sites-enabled/*; -} \ No newline at end of file +} diff --git a/service-ping/Dockerfile b/service-ping/Dockerfile index 416030e..d55fc99 100644 --- a/service-ping/Dockerfile +++ b/service-ping/Dockerfile @@ -1,8 +1,13 @@ FROM 21dotco/two1:base MAINTAINER 21.co -ADD . /usr/src/app - RUN apk add --no-cache linux-headers -RUN pip3 install -r /usr/src/app/requirements.txt -CMD sh -c "python3 /usr/src/app/utils/login.py && sleep 2 && python3 /usr/src/app/utils/update_manifest.py && sleep 2 && python3 /usr/src/app/server.py" + +WORKDIR /usr/src/app +COPY . ./ + +RUN pip3 install -e . -U + +COPY ping-entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/ping-entrypoint.sh +ENTRYPOINT ["ping-entrypoint.sh"] diff --git a/service-ping/ping-entrypoint.sh b/service-ping/ping-entrypoint.sh new file mode 100755 index 0000000..6a25a4e --- /dev/null +++ b/service-ping/ping-entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +python3 utils/login.py && sleep 2 && python3 utils/update_manifest.py && sleep 2 && python3 server.py diff --git a/service-ping/requirements.txt b/service-ping/requirements.txt deleted file mode 100644 index 6290083..0000000 --- a/service-ping/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -docopt==0.6.2 -Flask==0.10.1 -geocoder==1.9.0 -gunicorn==19.4.5 -psutil==4.1.0 -PyYAML==3.11 -requests==2.7.0 diff --git a/service-ping/setup.py b/service-ping/setup.py new file mode 100644 index 0000000..12ae02d --- /dev/null +++ b/service-ping/setup.py @@ -0,0 +1,16 @@ +import setuptools + +setuptools.setup( + name='ping', + version='0.0.1', + packages=setuptools.find_packages(), + install_requires=[ + "docopt==0.6.2", + "Flask==0.10.1", + "geocoder==1.9.0", + "gunicorn==19.4.5", + "psutil==4.1.0", + "PyYAML==3.11", + "requests==2.7.0", + ], +) diff --git a/service-ping/utils/update_manifest.py b/service-ping/utils/update_manifest.py index cc2a98d..4b37b07 100644 --- a/service-ping/utils/update_manifest.py +++ b/service-ping/utils/update_manifest.py @@ -1,20 +1,26 @@ import os - import yaml manifest_path = '/usr/src/app/manifest.yaml' -zt_ip, port = os.environ['PAYMENT_SERVER_IP'].replace('https://', '').replace('http://', '').split(':') +zt_ip, port = os.environ['PAYMENT_SERVER_IP'].replace('https://', '').replace('http://', '').rsplit(':', 1) + + +def update(): + """Update manifest with host IP.""" + with open(manifest_path, "r") as f: + manifest_json = yaml.load(f) + + service = os.environ['SERVICE'] + manifest_json["basePath"] = "/%s" % service + manifest_json["host"] = "%s:%s" % (zt_ip, port) + try: + manifest_json["info"]["x-21-quick-buy"] = manifest_json["info"]["x-21-quick-buy"] % (zt_ip, port, service) + except: + pass -with open(manifest_path, "r") as f: - manifest_json = yaml.load(f) + with open(manifest_path, "w") as f: + yaml.dump(manifest_json, f) -service = os.environ['SERVICE'] -manifest_json["basePath"] = "/%s" % service -manifest_json["host"] = "%s:%s" % (zt_ip, port) -try: - manifest_json["info"]["x-21-quick-buy"] = manifest_json["info"]["x-21-quick-buy"] % (zt_ip, port, service) -except: - pass -with open(manifest_path, "w") as f: - yaml.dump(manifest_json, f) +if __name__ == "__main__": + update()