From edd281d430484d56f93c2be8e882f8183534e002 Mon Sep 17 00:00:00 2001 From: Attawit Kittikrairit Date: Wed, 22 Aug 2018 01:03:43 +0700 Subject: [PATCH 01/11] Add docker-related files --- Dockerfile | 35 +++++++++++++++++++++++++++++++++++ docker/README.md | 28 ++++++++++++++++++++++++++++ docker/start_script.sh | 7 +++++++ 3 files changed, 70 insertions(+) create mode 100644 Dockerfile create mode 100644 docker/README.md create mode 100755 docker/start_script.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..4f26e6409 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# python 3 +FROM continuumio/anaconda3 + +MAINTAINER Attawit Kittikrairit + +# set working directory +WORKDIR /usr/src/app + +# clone from repo +RUN git clone https://github.com/e-mission/e-mission-server.git . + +# setup python environment +RUN conda env update --name emission --file setup/environment36.yml +RUN /bin/bash -c "source activate emission; pip install six --upgrade" + +# install nodejs, npm and bower +RUN apt-get update +RUN apt-get install -y build-essential +RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - +RUN apt-get -y install nodejs +RUN npm install -g bower +WORKDIR /usr/src/app/webapp +RUN bower update --allow-root +WORKDIR /usr/src/app + +# install nano for editing +RUN apt-get -y install nano + +# start the server +ADD docker/start_script.sh /usr/src/app/start_script.sh +RUN chmod u+x /usr/src/app/start_script.sh + +EXPOSE 8080 + +CMD ["/bin/bash", "/usr/src/app/start_script.sh"] \ No newline at end of file diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..566468f4f --- /dev/null +++ b/docker/README.md @@ -0,0 +1,28 @@ +### Docker Usage Instructions + +1. Build docker image + + ``` + docker build -t e-mission-server:latest . + ``` + +2. Create docker network + + ``` + docker network create e-mission --driver=bridge + ``` + +3. Run the server + + Assuming `config` files are located at `docker/config` folder + + ``` + docker run -d \ + -p 8080:8080 \ + --name=e-mission-server-1 \ + --net="e-mission" \ + --mount type=bind,source="$(pwd)"/docker/config/db.conf,target=/usr/src/app/conf/storage/db.conf,readonly \ + --mount type=bind,source="$(pwd)"/docker/config/webserver.conf,target=/usr/src/app/conf/net/api/webserver.conf,readonly \ + --mount type=bind,source="$(pwd)"/docker/config/google_auth.json,target=/usr/src/app/conf/net/auth/google_auth.json,readonly \ + e-mission-server:latest + ``` diff --git a/docker/start_script.sh b/docker/start_script.sh new file mode 100755 index 000000000..293716cb8 --- /dev/null +++ b/docker/start_script.sh @@ -0,0 +1,7 @@ +#!bin/bash + +# change python environment +source activate emission + +# launch the webapp +./e-mission-py.bash emission/net/api/cfc_webapp.py From 873b186fb11f703df9651e93dc0426a8a87c27a7 Mon Sep 17 00:00:00 2001 From: Attawit Kittikrairit Date: Thu, 23 Aug 2018 10:12:37 +0700 Subject: [PATCH 02/11] Add running MongoDB on Docker --- docker/README.md | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index 566468f4f..2e1dc3290 100644 --- a/docker/README.md +++ b/docker/README.md @@ -8,11 +8,46 @@ 2. Create docker network + We will be creating network name `e-mission` which will allows any docker container in the network refer to each other by its `name` instead of IP Address which can be changed over time. + ``` docker network create e-mission --driver=bridge ``` -3. Run the server +3. Run MongoDB + + We will be using Official MongoDB Docker image, so no need to build one. + + ``` + docker run -d \ + --name=e-mission-mongo-1 \ + --net="e-mission" \ + --restart=always \ + --mount source=e-mission-mongo-1_data,target=/data/db \ + --mount source=e-mission-mongo-1_config,target=/data/configdb \ + mongo:latest \ + --bind_ip_all + ``` + + FOR ADVANCED USER: If you would like to access to MongoDB directly for debugging purpose, you can add the line + + ``` + -p 27017:27017 \ + ``` + + and access it like MongoDB is running on your host machine. + +4. Configure `db.conf` + + ``` + { + "timeseries": { + "url": "e-mission-mongo-1" + } + } + ``` + +5. Run the server Assuming `config` files are located at `docker/config` folder @@ -21,6 +56,7 @@ -p 8080:8080 \ --name=e-mission-server-1 \ --net="e-mission" \ + --restart=always \ --mount type=bind,source="$(pwd)"/docker/config/db.conf,target=/usr/src/app/conf/storage/db.conf,readonly \ --mount type=bind,source="$(pwd)"/docker/config/webserver.conf,target=/usr/src/app/conf/net/api/webserver.conf,readonly \ --mount type=bind,source="$(pwd)"/docker/config/google_auth.json,target=/usr/src/app/conf/net/auth/google_auth.json,readonly \ From d8b248b0b15494393806fd82cd6fbf027d9c76f6 Mon Sep 17 00:00:00 2001 From: shankari Date: Fri, 16 Nov 2018 12:07:48 +0700 Subject: [PATCH 03/11] Update Dockerfile Co-Authored-By: atton16 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4f26e6409..5d5b1ea92 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # python 3 -FROM continuumio/anaconda3 +FROM continuumio/miniconda3 MAINTAINER Attawit Kittikrairit @@ -32,4 +32,4 @@ RUN chmod u+x /usr/src/app/start_script.sh EXPOSE 8080 -CMD ["/bin/bash", "/usr/src/app/start_script.sh"] \ No newline at end of file +CMD ["/bin/bash", "/usr/src/app/start_script.sh"] From f0c26201b57ac827279840b4573339c207cb2a32 Mon Sep 17 00:00:00 2001 From: shankari Date: Fri, 16 Nov 2018 12:08:13 +0700 Subject: [PATCH 04/11] Update Dockerfile Co-Authored-By: atton16 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5d5b1ea92..c0abf4a35 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ RUN bower update --allow-root WORKDIR /usr/src/app # install nano for editing -RUN apt-get -y install nano +RUN apt-get -y install nano vim # start the server ADD docker/start_script.sh /usr/src/app/start_script.sh From a08eb874ab04b5882642952d5dc64f62fcb71c57 Mon Sep 17 00:00:00 2001 From: Attawit Kittikrairit Date: Fri, 16 Nov 2018 12:08:53 +0700 Subject: [PATCH 05/11] Update Dockerfile --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c0abf4a35..473e1df9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,6 @@ RUN /bin/bash -c "source activate emission; pip install six --upgrade" # install nodejs, npm and bower RUN apt-get update -RUN apt-get install -y build-essential RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - RUN apt-get -y install nodejs RUN npm install -g bower From a4ff8963c3acf0b27eb9ad3992d42e0571baf1d6 Mon Sep 17 00:00:00 2001 From: shankari Date: Fri, 16 Nov 2018 12:09:08 +0700 Subject: [PATCH 06/11] Update docker/README.md Co-Authored-By: atton16 --- docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index 2e1dc3290..4eb82f9fc 100644 --- a/docker/README.md +++ b/docker/README.md @@ -57,7 +57,7 @@ --name=e-mission-server-1 \ --net="e-mission" \ --restart=always \ - --mount type=bind,source="$(pwd)"/docker/config/db.conf,target=/usr/src/app/conf/storage/db.conf,readonly \ + --mount type=bind,source="$(pwd)"/conf/storage/db.conf.docker.sample,target=/usr/src/app/conf/storage/db.conf,readonly \ --mount type=bind,source="$(pwd)"/docker/config/webserver.conf,target=/usr/src/app/conf/net/api/webserver.conf,readonly \ --mount type=bind,source="$(pwd)"/docker/config/google_auth.json,target=/usr/src/app/conf/net/auth/google_auth.json,readonly \ e-mission-server:latest From 54b35c069b5aac03bf14793e85a5722ff894c821 Mon Sep 17 00:00:00 2001 From: shankari Date: Fri, 16 Nov 2018 12:09:17 +0700 Subject: [PATCH 07/11] Update docker/README.md Co-Authored-By: atton16 --- docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index 4eb82f9fc..9782b5935 100644 --- a/docker/README.md +++ b/docker/README.md @@ -58,7 +58,7 @@ --net="e-mission" \ --restart=always \ --mount type=bind,source="$(pwd)"/conf/storage/db.conf.docker.sample,target=/usr/src/app/conf/storage/db.conf,readonly \ - --mount type=bind,source="$(pwd)"/docker/config/webserver.conf,target=/usr/src/app/conf/net/api/webserver.conf,readonly \ + --mount type=bind,source="$(pwd)"/conf/net/api/webserver.conf.docker.sample,target=/usr/src/app/conf/net/api/webserver.conf,readonly \ --mount type=bind,source="$(pwd)"/docker/config/google_auth.json,target=/usr/src/app/conf/net/auth/google_auth.json,readonly \ e-mission-server:latest ``` From 55457921bb40fa376dfe74483ebc4d1d3f2f2188 Mon Sep 17 00:00:00 2001 From: shankari Date: Fri, 16 Nov 2018 12:09:34 +0700 Subject: [PATCH 08/11] Update docker/README.md Co-Authored-By: atton16 --- docker/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index 9782b5935..460e020b9 100644 --- a/docker/README.md +++ b/docker/README.md @@ -59,6 +59,5 @@ --restart=always \ --mount type=bind,source="$(pwd)"/conf/storage/db.conf.docker.sample,target=/usr/src/app/conf/storage/db.conf,readonly \ --mount type=bind,source="$(pwd)"/conf/net/api/webserver.conf.docker.sample,target=/usr/src/app/conf/net/api/webserver.conf,readonly \ - --mount type=bind,source="$(pwd)"/docker/config/google_auth.json,target=/usr/src/app/conf/net/auth/google_auth.json,readonly \ e-mission-server:latest ``` From 752eb6d480aeec509439e59d50b069a0f67949e0 Mon Sep 17 00:00:00 2001 From: Attawit Kittikrairit Date: Sat, 17 Nov 2018 11:33:19 +0700 Subject: [PATCH 09/11] Update Dockerfile Restore installing build-essential and add cleanup scripts --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 473e1df9e..b6201036c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,7 @@ RUN /bin/bash -c "source activate emission; pip install six --upgrade" # install nodejs, npm and bower RUN apt-get update +RUN apt-get install build-essential RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - RUN apt-get -y install nodejs RUN npm install -g bower @@ -25,6 +26,10 @@ WORKDIR /usr/src/app # install nano for editing RUN apt-get -y install nano vim +# cleanup +RUN apt-get -y remove --purge build-essential +RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + # start the server ADD docker/start_script.sh /usr/src/app/start_script.sh RUN chmod u+x /usr/src/app/start_script.sh From 2f92ca8f37e0842647ef9ede98e42a488ffbc24d Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Sun, 18 Nov 2018 14:48:40 -0800 Subject: [PATCH 10/11] Add sample files for docker to simplify docker-based installation + fix the readme --- conf/net/api/webserver.conf.docker.sample | 16 ++++++++++++++++ conf/storage/db.conf.docker.sample | 5 +++++ docker/README.md | 14 +------------- 3 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 conf/net/api/webserver.conf.docker.sample create mode 100644 conf/storage/db.conf.docker.sample diff --git a/conf/net/api/webserver.conf.docker.sample b/conf/net/api/webserver.conf.docker.sample new file mode 100644 index 000000000..faf7caaad --- /dev/null +++ b/conf/net/api/webserver.conf.docker.sample @@ -0,0 +1,16 @@ +{ + "paths" : { + "static_path" : "webapp/www/", + "python_path" : "main", + "log_base_dir" : ".", + "log_file" : "debug.log" + }, + "__comment" : "Fill this in for the production server. port will almost certainly be 80 or 443. For iOS, using localhost allows you to test without an internet connection. For AWS and android, make sure that the host 0.0.0.0, localhost does not seem to work", + "server" : { + "host" : "0.0.0.0", + "port" : "8080", + "__comment": "1 hour = 60 min = 60 * 60 sec", + "timeout" : "3600", + "auth": "skip" + } +} diff --git a/conf/storage/db.conf.docker.sample b/conf/storage/db.conf.docker.sample new file mode 100644 index 000000000..dfd75cb4e --- /dev/null +++ b/conf/storage/db.conf.docker.sample @@ -0,0 +1,5 @@ +{ + "timeseries": { + "url": "e-mission-mongo-1" + } +} diff --git a/docker/README.md b/docker/README.md index 460e020b9..660a9d7c2 100644 --- a/docker/README.md +++ b/docker/README.md @@ -37,19 +37,7 @@ and access it like MongoDB is running on your host machine. -4. Configure `db.conf` - - ``` - { - "timeseries": { - "url": "e-mission-mongo-1" - } - } - ``` - -5. Run the server - - Assuming `config` files are located at `docker/config` folder +4. Run the server ``` docker run -d \ From 706be79a6f74fca3f64a6ab58fcff2ef1fe7506f Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Tue, 20 Nov 2018 12:43:42 -0800 Subject: [PATCH 11/11] Fix the install of build-essential Without the `-y`, the build dies at the prompt for "yes/no" This is a fix for https://github.com/e-mission/e-mission-server/pull/594/commits/752eb6d480aeec509439e59d50b069a0f67949e0 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b6201036c..c16f382f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ RUN /bin/bash -c "source activate emission; pip install six --upgrade" # install nodejs, npm and bower RUN apt-get update -RUN apt-get install build-essential +RUN apt-get install -y build-essential RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - RUN apt-get -y install nodejs RUN npm install -g bower