Skip to content

Commit

Permalink
sell: Update project for ipv6
Browse files Browse the repository at this point in the history
  • Loading branch information
jagranata committed Sep 16, 2016
1 parent 0446190 commit 4181955
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 32 deletions.
10 changes: 6 additions & 4 deletions payments/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"

WORKDIR /usr/src/app
COPY . ./

RUN pip3 install -e . -U
CMD sh -c "python3 utils/login.py && sleep 2 && python3 server.py"
2 changes: 0 additions & 2 deletions payments/requirements.txt

This file was deleted.

11 changes: 11 additions & 0 deletions payments/setup.py
Original file line number Diff line number Diff line change
@@ -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',
],
)
4 changes: 3 additions & 1 deletion router/Dockerfile
Original file line number Diff line number Diff line change
@@ -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;"
CMD nginx -g "daemon off;"
2 changes: 1 addition & 1 deletion router/files/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ http {
##

include /etc/nginx/sites-enabled/*;
}
}
13 changes: 9 additions & 4 deletions service-ping/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
3 changes: 3 additions & 0 deletions service-ping/ping-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

python3 utils/login.py && sleep 2 && python3 utils/update_manifest.py && sleep 2 && python3 server.py
7 changes: 0 additions & 7 deletions service-ping/requirements.txt

This file was deleted.

16 changes: 16 additions & 0 deletions service-ping/setup.py
Original file line number Diff line number Diff line change
@@ -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",
],
)
32 changes: 19 additions & 13 deletions service-ping/utils/update_manifest.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 4181955

Please sign in to comment.