diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..90d9e96 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +default.etcd +*.pyc \ No newline at end of file diff --git a/10-yaobank.yaml b/10-yaobank.yaml index 5fbc6e1..4504105 100644 --- a/10-yaobank.yaml +++ b/10-yaobank.yaml @@ -33,8 +33,8 @@ spec: serviceAccountName: database containers: - name: database - image: spikecurtis/yaobank-database:latest - imagePullPolicy: IfNotPresent + image: calico/yaobank-database:latest + imagePullPolicy: Always ports: - containerPort: 2379 command: ["etcd"] @@ -54,6 +54,7 @@ spec: ports: - port: 80 name: http + targetPort: 8000 selector: app: summary --- @@ -80,10 +81,10 @@ spec: serviceAccountName: summary containers: - name: summary - image: spikecurtis/yaobank-summary:latest + image: calico/yaobank-summary:latest imagePullPolicy: Always ports: - - containerPort: 80 + - containerPort: 8000 --- apiVersion: v1 kind: Service @@ -95,6 +96,7 @@ spec: ports: - port: 80 name: http + targetPort: 8000 selector: app: customer --- @@ -121,8 +123,8 @@ spec: serviceAccountName: customer containers: - name: customer - image: spikecurtis/yaobank-customer:latest + image: calico/yaobank-customer:latest imagePullPolicy: Always ports: - - containerPort: 80 + - containerPort: 8000 --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9bc6a8d --- /dev/null +++ b/Makefile @@ -0,0 +1,80 @@ +# The release version. +VERSION ?= v0.1 + +# Etcd version. Should match the version in the database/Dockerfile. +ETCD_VERSION ?= v3.3.7 + +# Constants +PYTHON_VERSION ?= 2.7 + +.PHONY: calico/yaobank-customer +calico/yaobank-customer: + docker build -t $@ customer + +.PHONY: calico/yaobank-summary +calico/yaobank-summary: + docker build -t $@ summary + +.PHONY: calico/yaobank-database +calico/yaobank-database: database/default.etcd + # Create a packaged etcd with the populated data (this also modifies group/user settings for this data which is + # required for OpenShift). + docker build -t $@ database + +database/default.etcd: database/data.txt database/loaddata.py + # Start an etcd server + -docker rm -f yaobank-etcd + docker run --detach \ + --net=host \ + --entrypoint=/usr/local/bin/etcd \ + --name yaobank-etcd quay.io/coreos/etcd:$(ETCD_VERSION) \ + --advertise-client-urls "http://$(LOCAL_IP_ENV):2379,http://127.0.0.1:2379,http://$(LOCAL_IP_ENV):4001,http://127.0.0.1:4001" \ + --listen-client-urls "http://0.0.0.0:2379,http://0.0.0.0:4001" + # Run the python population script + docker run --net=host -v $(CURDIR)/database:/database python:$(PYTHON_VERSION) sh -c "pip install python-etcd && cd /database && python loaddata.py" + # Copy out the default.etcd data from the etcd container and delete the etcd container + docker cp yaobank-etcd:/default.etcd $(CURDIR)/database + docker rm -f yaobank-etcd + +.PHONY: clean +clean: + -rm -rf database/default.etcd + -docker rmi calico/yaobank-customer:latest + -docker rmi calico/yaobank-summary:latest + -docker rmi calico/yaobank-database:latest + -docker rmi calico/yaobank-customer:$(VERSION) + -docker rmi calico/yaobank-summary:$(VERSION) + -docker rmi calico/yaobank-database:$(VERSION) + -docker rmi quay.io/calico/yaobank-customer:latest + -docker rmi quay.io/calico/yaobank-summary:latest + -docker rmi quay.io/calico/yaobank-database:latest + -docker rmi quay.io/calico/yaobank-customer:$(VERSION) + -docker rmi quay.io/calico/yaobank-summary:$(VERSION) + -docker rmi quay.io/calico/yaobank-database:$(VERSION) + +.PHONY: release +release: calico/yaobank-customer calico/yaobank-summary calico/yaobank-database + docker tag calico/yaobank-customer:latest calico/yaobank-customer:$(VERSION) + docker tag calico/yaobank-summary:latest calico/yaobank-summary:$(VERSION) + docker tag calico/yaobank-database:latest calico/yaobank-database:$(VERSION) + docker tag calico/yaobank-customer:latest quay.io/calico/yaobank-customer:latest + docker tag calico/yaobank-summary:latest quay.io/calico/yaobank-summary:latest + docker tag calico/yaobank-database:latest quay.io/calico/yaobank-database:latest + docker tag calico/yaobank-customer:latest quay.io/calico/yaobank-customer:$(VERSION) + docker tag calico/yaobank-summary:latest quay.io/calico/yaobank-summary:$(VERSION) + docker tag calico/yaobank-database:latest quay.io/calico/yaobank-database:$(VERSION) + +.PHONY: push +push: + docker push calico/yaobank-customer:latest + docker push calico/yaobank-summary:latest + docker push calico/yaobank-database:latest + docker push calico/yaobank-customer:$(VERSION) + docker push calico/yaobank-summary:$(VERSION) + docker push calico/yaobank-database:$(VERSION) + docker push quay.io/calico/yaobank-customer:latest + docker push quay.io/calico/yaobank-summary:latest + docker push quay.io/calico/yaobank-database:latest + docker push quay.io/calico/yaobank-customer:$(VERSION) + docker push quay.io/calico/yaobank-summary:$(VERSION) + docker push quay.io/calico/yaobank-database:$(VERSION) diff --git a/customer/customer.py b/customer/customer.py index 7314304..8dd2ef6 100644 --- a/customer/customer.py +++ b/customer/customer.py @@ -12,4 +12,4 @@ def home(): return render_template("accountsummary.html", **summary) if __name__ == "__main__": - app.run(host="0.0.0.0", port=80) \ No newline at end of file + app.run(host="0.0.0.0", port=8000) \ No newline at end of file diff --git a/database/Dockerfile b/database/Dockerfile new file mode 100644 index 0000000..c2c2669 --- /dev/null +++ b/database/Dockerfile @@ -0,0 +1,6 @@ +FROM quay.io/coreos/etcd:v3.3.7 + +# Copy in the default data files and set group/user permissions. +COPY default.etcd /default.etcd +RUN chgrp -R 0 /default.etcd && \ + chmod -R g=u /default.etcd diff --git a/summary/summary.py b/summary/summary.py index 1624a6c..7e708b9 100644 --- a/summary/summary.py +++ b/summary/summary.py @@ -15,4 +15,4 @@ def get_summary(userid): return jsonify(summary) if __name__ == "__main__": - app.run(host="0.0.0.0", port=80) \ No newline at end of file + app.run(host="0.0.0.0", port=8000) \ No newline at end of file