From 261eb03102ae67c5770270878f84330226dc9890 Mon Sep 17 00:00:00 2001 From: Mano Marks Date: Mon, 25 Apr 2016 11:28:21 -0700 Subject: [PATCH 1/3] adding in improvements from when we ran the birthday party app. Mostly fixed the Dockerfiles so they use Alpine for the base images. That required re-working the Java worker Docker file. Removed links from compose file. cleaned up a few things like a tab instead of a space in app.py --- docker-compose.yml | 13 +++---------- result-app/Dockerfile | 4 ++-- result-app/views/index.html | 2 +- voting-app/Dockerfile | 6 +++--- voting-app/app.py | 3 ++- worker/Dockerfile | 10 +++++++--- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b9a418c..06ec77b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,8 +7,6 @@ services: - ./voting-app:/app ports: - "5000:80" - links: - - redis networks: - front-tier - back-tier @@ -19,28 +17,25 @@ services: - ./result-app:/app ports: - "5001:80" - links: - - db networks: - front-tier - back-tier worker: build: ./worker - links: - - db - - redis networks: - back-tier redis: - image: redis + image: redis:alpine + container_name: redis ports: ["6379"] networks: - back-tier db: image: postgres:9.4 + container_name: db volumes: - "db-data:/var/lib/postgresql/data" networks: @@ -52,5 +47,3 @@ volumes: networks: front-tier: back-tier: - - diff --git a/result-app/Dockerfile b/result-app/Dockerfile index bf9c002..a93ab6e 100644 --- a/result-app/Dockerfile +++ b/result-app/Dockerfile @@ -1,9 +1,9 @@ -FROM node:0.10 +FROM mhart/alpine-node -RUN mkdir /app WORKDIR /app ADD package.json /app/package.json +RUN npm config set registry http://registry.npmjs.org RUN npm install && npm ls RUN mv /app/node_modules /node_modules diff --git a/result-app/views/index.html b/result-app/views/index.html index c2ae1f9..2a97853 100644 --- a/result-app/views/index.html +++ b/result-app/views/index.html @@ -6,7 +6,7 @@ - + diff --git a/voting-app/Dockerfile b/voting-app/Dockerfile index c7f79d6..1fdec68 100644 --- a/voting-app/Dockerfile +++ b/voting-app/Dockerfile @@ -1,5 +1,5 @@ # Using official python runtime base image -FROM python:2.7 +FROM python:2.7-alpine # Set the application directory WORKDIR /app @@ -11,8 +11,8 @@ RUN pip install -r requirements.txt # Copy our code from the current folder to /app inside the container ADD . /app -# Make port 5000 available for links and/or publish -EXPOSE 80 +# Make port 80 available for links and/or publish +EXPOSE 80 # Define our command to be run when launching the container CMD ["python", "app.py"] diff --git a/voting-app/app.py b/voting-app/app.py index f811045..d2b4b51 100644 --- a/voting-app/app.py +++ b/voting-app/app.py @@ -36,9 +36,10 @@ def hello(): hostname=hostname, vote=vote, )) + resp.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'; resp.set_cookie('voter_id', voter_id) return resp if __name__ == "__main__": - app.run(host='0.0.0.0', port=80, debug=True) + app.run(host='0.0.0.0', port=80, debug=True) diff --git a/worker/Dockerfile b/worker/Dockerfile index a9611d7..5015993 100644 --- a/worker/Dockerfile +++ b/worker/Dockerfile @@ -1,6 +1,10 @@ -FROM java:7 +FROM java:openjdk-8-jdk-alpine -RUN apt-get update -qq && apt-get install -y maven && apt-get clean +RUN MAVEN_VERSION=3.3.3 \ + && cd /usr/share \ + && wget http://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz -O - | tar xzf - \ + && mv /usr/share/apache-maven-$MAVEN_VERSION /usr/share/maven \ + && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn WORKDIR /code @@ -12,4 +16,4 @@ RUN ["mvn", "verify"] ADD src /code/src RUN ["mvn", "package"] -CMD ["/usr/lib/jvm/java-7-openjdk-amd64/bin/java", "-jar", "target/worker-jar-with-dependencies.jar"] +CMD ["java", "-jar", "target/worker-jar-with-dependencies.jar"] From be0e4e2ff2d66b00168e0bbb97979de1acc7af1c Mon Sep 17 00:00:00 2001 From: Mano Marks Date: Mon, 25 Apr 2016 12:04:59 -0700 Subject: [PATCH 2/3] fixing app.py --- voting-app/app.py | 1 - voting-app/utils/__init__.pyc | Bin 0 -> 647 bytes 2 files changed, 1 deletion(-) create mode 100644 voting-app/utils/__init__.pyc diff --git a/voting-app/app.py b/voting-app/app.py index d2b4b51..df556b5 100644 --- a/voting-app/app.py +++ b/voting-app/app.py @@ -36,7 +36,6 @@ def hello(): hostname=hostname, vote=vote, )) - resp.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'; resp.set_cookie('voter_id', voter_id) return resp diff --git a/voting-app/utils/__init__.pyc b/voting-app/utils/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ddf86614615c711814925d5495d7204ed7ab1893 GIT binary patch literal 647 zcmah`O;5r=5S?iOfk-qOI2tY{J*fNvV@!x2Cl18~Lo^N21{X_PyW2z(JmEj~;8EW! z6_0MZud_36X5Q?&pRMNCs~I8gFceVy1;dV}}+lja}l~&1vdCK@NpcDUfWbb`a zk3GVSL$86(10`bgA>dbOGV7YOo7)Lww&zqEXhHiY1tfg{D9KT{{~3@okQ%@C7X2O7w(gL3d#F zCRx@ijEZ$H2vnj>5S(R8vyV`zC@^VYGvx(r4snaCPJ>-;bCauFmot0z9YvsD7r-W~ c!k2sdYx{3+$v$7CVG&0cGKH3!yWDYq0R19;ssI20 literal 0 HcmV?d00001 From 3978756bb2b6d964c80c9961933818d9b0ef2687 Mon Sep 17 00:00:00 2001 From: Mano Marks Date: Tue, 3 May 2016 19:35:26 -0700 Subject: [PATCH 3/3] Moving result app to be based on node:5.11.0-slim, adding back links in docker-compose.yml, and removing explicit container names --- docker-compose.yml | 9 +++++++-- result-app/Dockerfile | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 06ec77b..440ee47 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,8 @@ services: - ./voting-app:/app ports: - "5000:80" + links: + - redis networks: - front-tier - back-tier @@ -17,25 +19,28 @@ services: - ./result-app:/app ports: - "5001:80" + links: + - db networks: - front-tier - back-tier worker: build: ./worker + links: + - db + - redis networks: - back-tier redis: image: redis:alpine - container_name: redis ports: ["6379"] networks: - back-tier db: image: postgres:9.4 - container_name: db volumes: - "db-data:/var/lib/postgresql/data" networks: diff --git a/result-app/Dockerfile b/result-app/Dockerfile index a93ab6e..3045ede 100644 --- a/result-app/Dockerfile +++ b/result-app/Dockerfile @@ -1,4 +1,4 @@ -FROM mhart/alpine-node +FROM node:5.11.0-slim WORKDIR /app