From e7cd5f559797f35ac5611ad4e98503169b3a9829 Mon Sep 17 00:00:00 2001 From: javier morales Date: Wed, 6 Sep 2017 13:13:44 -0300 Subject: [PATCH 1/8] Agrego Dockerfile del modulo de reportes, modifico el archivo run.sh --- adkintunmobile/server/reports/Dockerfile | 39 ++++++++++++++++++++++++ adkintunmobile/server/run.sh | 23 +++++++++----- 2 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 adkintunmobile/server/reports/Dockerfile diff --git a/adkintunmobile/server/reports/Dockerfile b/adkintunmobile/server/reports/Dockerfile new file mode 100644 index 0000000..60417a6 --- /dev/null +++ b/adkintunmobile/server/reports/Dockerfile @@ -0,0 +1,39 @@ +## Header +FROM python:3.5.4-alpine3.4 +MANTAINER Javier Morales + +## Dependencies +# install apt dependencies +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + gcc \ + git \ + libpq-dev \ + make + +# clone project +RUN mkdir /adk && \ + cd /adk && \ + git clone https://github.com/niclabs/adkintun-reports && \ + cd adkintun-reports + +# install pip dependencies +RUN cd /adk/adkintun-reports && \ + pip install -r requirements.txt + +## Clean Up +# cleaning up apt dependencies +RUN apt-get purge -y \ + gcc \ + git \ + libpq-dev \ + make + +# cleaning up list of available packages +RUN rm -rf /var/lib/apt/lists/* + +## Run command +#run uwsgi +CMD cd /adk/adkintun-reports && \ +uwsgi --socket 0.0.0.0:8000 --processes $(nproc) -w app:application --mule + diff --git a/adkintunmobile/server/run.sh b/adkintunmobile/server/run.sh index 1e68f15..f349754 100755 --- a/adkintunmobile/server/run.sh +++ b/adkintunmobile/server/run.sh @@ -21,6 +21,8 @@ function build { docker build --tag populate-adk . cd "$DIR/server" docker build --tag server-adk . + cd "$DIR/reports" + docker build --tag reports-adk . } @@ -75,37 +77,42 @@ function run { --rm populate-adk # Run server docker docker run --name server-adk --link postgres-adk:postgres -v $(pwd)/config.py:/adk/AdkintunMobile-Server/config.py \ - -v $(pwd)/reports:/adk/AdkintunMobile-Server/app/static/reports -v $(pwd)/tmp:/adk/AdkintunMobile-Server/tmp \ - -v /etc/localtime:/etc/localtime:ro --restart=unless-stopped --log-opt max-size=50m -d server-adk + -v $(pwd)/tmp:/adk/AdkintunMobile-Server/tmp -v /etc/localtime:/etc/localtime:ro --restart=unless-stopped --log-opt\ + max-size=50m -d server-adk + # Run reports docker + docker run --name reports-adk --link postgres-adk:postgres -v $(pwd)/reports/config.py:/adk/adkintun-reports/config.py \ + -v $(pwd)/reports:/adk/adkintun-reports/app/static/reports -v $(pwd)/reports/tmp:/adk/adkintun-reports/tmp \ + -v /etc/localtime:/etc/localtime:ro --restart=unless-stopped --log-opt max-size=50m -d reports-adk # Run the nginx server docker - docker run --name nginx-adk -v $(pwd)/nginx.conf:/etc/nginx/conf.d/adk.conf:ro --link server-adk:server-adk -p 80:80 \ - -v /etc/localtime:/etc/localtime:ro --restart=unless-stopped --log-opt max-size=50m -d nginx + docker run --name nginx-adk -v $(pwd)/nginx.conf:/etc/nginx/conf.d/adk.conf:ro --link server-adk:server-adk\ + --link reports-adk:reports-adk -p 80:80 -v /etc/localtime:/etc/localtime:ro --restart=unless-stopped --log-opt\ + max-size=50m -d nginx } function stop { #Stop the aplication - docker stop postgres-adk server-adk nginx-adk + docker stop postgres-adk server-adk reports-adk nginx-adk } function start { #start the aplication - docker start postgres-adk server-adk nginx-adk + docker start postgres-adk server-adk reports-adk nginx-adk } function restart { #start the aplication - docker restart postgres-adk server-adk nginx-adk + docker restart postgres-adk server-adk reports-adk nginx-adk } function delete { #Stop application and delete all data stop; - docker rm -f postgres-adk server-adk nginx-adk + docker rm -f postgres-adk server-adk reports-adk nginx-adk } From 6ebdca8411332f56e061e9db083cc35976369bdc Mon Sep 17 00:00:00 2001 From: javier-op Date: Wed, 6 Sep 2017 13:24:47 -0300 Subject: [PATCH 2/8] Agrego archivo config para modulo de reportes. --- adkintunmobile/server/reports/config.py | 41 +++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 adkintunmobile/server/reports/config.py diff --git a/adkintunmobile/server/reports/config.py b/adkintunmobile/server/reports/config.py new file mode 100644 index 0000000..268d50f --- /dev/null +++ b/adkintunmobile/server/reports/config.py @@ -0,0 +1,41 @@ +class DefaultConfig(object): + DEBUG = False + TESTING = False + CSRF_ENABLED = True + BIND_KEY = "frontend" + USER_SERVER = "this-should-be-changed" + SECRET_KEY_SERVER = "this-should-be-changed" + HOST_SERVER = "this-should-be-changed" + DB_NAME_SERVER = "this-should-be-changed" + USER_FRONTEND = "this-should-be-changed" + SECRET_KEY_FRONTEND = "this-should-be-changed" + HOST_FRONTEND = "this-should-be-changed" + DB_NAME_FRONTEND = "this-should-be-changed" + SQLALCHEMY_DATABASE_URI = "postgresql://{}:{}@{}/{}".format(USER_SERVER, SECRET_KEY_SERVER, + HOST_SERVER, DB_NAME_SERVER) + SQLALCHEMY_BINDS = { + BIND_KEY: "postgresql://{}:{}@{}/{}".format(USER_FRONTEND, SECRET_KEY_FRONTEND, + HOST_FRONTEND, DB_NAME_FRONTEND) + } + SQLALCHEMY_TRACK_MODIFICATIONS = True + + +class TestConfig(object): + USER = "this-should-be-changed" + SECRET_KEY = "this-should-be-changed" + BIND_KEY = "frontend" + SQLALCHEMY_DATABASE_URI = "postgresql://" + USER + ":" + SECRET_KEY + "@localhost/this-should-be-changed" + SQLALCHEMY_BINDS = { + BIND_KEY: "postgresql://" + USER + ":" + SECRET_KEY + "@localhost/this-should-be-changed" + } + SQLALCHEMY_TRACK_MODIFICATIONS = True + PRESERVE_CONTEXT_ON_EXCEPTION = False + TESTING = True + DEBUG = True + + +class Files: + STATIC_FILES_FOLDER = "app/static" + REPORTS_FOLDER = STATIC_FILES_FOLDER + "/" + "reports" + LOGS_FOLDER = "tmp" + REPORTS_LOG_FILE = "report.log" From b7e609714eeb150283c723c00ae7a9f083b75783 Mon Sep 17 00:00:00 2001 From: javier-op Date: Mon, 11 Sep 2017 12:32:54 -0300 Subject: [PATCH 3/8] Actualizo nginx.conf --- adkintunmobile/server/nginx.conf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/adkintunmobile/server/nginx.conf b/adkintunmobile/server/nginx.conf index a2defe3..9640fba 100644 --- a/adkintunmobile/server/nginx.conf +++ b/adkintunmobile/server/nginx.conf @@ -5,4 +5,10 @@ server{ uwsgi_pass server-adk:8000; client_max_body_size 31M; } + + location /reports/ { + include uwsgi_params; + uwsgi_pass reports-adk:8000; + client_max_body_size 31M; + } } From 2f60cedaf4248928638bccf78f5655defca670f2 Mon Sep 17 00:00:00 2001 From: javier-op Date: Mon, 11 Sep 2017 12:36:05 -0300 Subject: [PATCH 4/8] Actualizo reports/config.py --- adkintunmobile/server/reports/config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/adkintunmobile/server/reports/config.py b/adkintunmobile/server/reports/config.py index 268d50f..51ca05f 100644 --- a/adkintunmobile/server/reports/config.py +++ b/adkintunmobile/server/reports/config.py @@ -3,16 +3,18 @@ class DefaultConfig(object): TESTING = False CSRF_ENABLED = True BIND_KEY = "frontend" + USER_SERVER = "this-should-be-changed" SECRET_KEY_SERVER = "this-should-be-changed" HOST_SERVER = "this-should-be-changed" DB_NAME_SERVER = "this-should-be-changed" + SQLALCHEMY_DATABASE_URI = "postgresql://{}:{}@{}/{}".format(USER_SERVER, SECRET_KEY_SERVER, + HOST_SERVER, DB_NAME_SERVER) + USER_FRONTEND = "this-should-be-changed" SECRET_KEY_FRONTEND = "this-should-be-changed" HOST_FRONTEND = "this-should-be-changed" DB_NAME_FRONTEND = "this-should-be-changed" - SQLALCHEMY_DATABASE_URI = "postgresql://{}:{}@{}/{}".format(USER_SERVER, SECRET_KEY_SERVER, - HOST_SERVER, DB_NAME_SERVER) SQLALCHEMY_BINDS = { BIND_KEY: "postgresql://{}:{}@{}/{}".format(USER_FRONTEND, SECRET_KEY_FRONTEND, HOST_FRONTEND, DB_NAME_FRONTEND) From f575796b652f9cc0f8aef36540cb31a81e42c1cb Mon Sep 17 00:00:00 2001 From: javier-op Date: Wed, 13 Sep 2017 15:13:09 -0300 Subject: [PATCH 5/8] Detalles de configuraciones. --- adkintunmobile/server/runcommands.txt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 adkintunmobile/server/runcommands.txt diff --git a/adkintunmobile/server/runcommands.txt b/adkintunmobile/server/runcommands.txt new file mode 100644 index 0000000..9b9e59b --- /dev/null +++ b/adkintunmobile/server/runcommands.txt @@ -0,0 +1,8 @@ +docker run --name reports-adk --link postgres-adk3:postgres-adk3 --link postgres-report:postgres-report \ +-v $(pwd)/reports/config.py:/adk/adkintun-reports/config.py -v $(pwd)/reports:/adk/adkintun-reports/app/static/reports \ +-v $(pwd)/reports/tmp:/adk/adkintun-reports/tmp -v /etc/localtime:/etc/localtime:ro --restart=unless-stopped \ +--log-opt max-size=50m -m 2g -d reports-adk + +docker run --name nginx-adk -v $(pwd)/nginx.conf:/etc/nginx/conf.d/adk.conf:ro \ +--link reports-adk:reports-adk -p 8080:80 -v /etc/localtime:/etc/localtime:ro --restart=unless-stopped \ +--log-opt max-size=50m -m 2g -d nginx From 5019f3fabb49545b2a7afc4a69681ca9049d20eb Mon Sep 17 00:00:00 2001 From: javier-op Date: Fri, 15 Sep 2017 14:40:10 -0300 Subject: [PATCH 6/8] Actualizo configuraciones. --- adkintunmobile/server/nginx.conf | 5 ----- adkintunmobile/server/reports/Dockerfile | 4 ++-- adkintunmobile/server/runcommands.txt | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/adkintunmobile/server/nginx.conf b/adkintunmobile/server/nginx.conf index 9640fba..480f3b7 100644 --- a/adkintunmobile/server/nginx.conf +++ b/adkintunmobile/server/nginx.conf @@ -6,9 +6,4 @@ server{ client_max_body_size 31M; } - location /reports/ { - include uwsgi_params; - uwsgi_pass reports-adk:8000; - client_max_body_size 31M; - } } diff --git a/adkintunmobile/server/reports/Dockerfile b/adkintunmobile/server/reports/Dockerfile index 60417a6..9a0ca65 100644 --- a/adkintunmobile/server/reports/Dockerfile +++ b/adkintunmobile/server/reports/Dockerfile @@ -1,6 +1,6 @@ ## Header -FROM python:3.5.4-alpine3.4 -MANTAINER Javier Morales +FROM python:3.5.1-slim +MAINTAINER Javier Morales ## Dependencies # install apt dependencies diff --git a/adkintunmobile/server/runcommands.txt b/adkintunmobile/server/runcommands.txt index 9b9e59b..d406681 100644 --- a/adkintunmobile/server/runcommands.txt +++ b/adkintunmobile/server/runcommands.txt @@ -1,5 +1,5 @@ docker run --name reports-adk --link postgres-adk3:postgres-adk3 --link postgres-report:postgres-report \ --v $(pwd)/reports/config.py:/adk/adkintun-reports/config.py -v $(pwd)/reports:/adk/adkintun-reports/app/static/reports \ +-v $(pwd)/reports/config.py:/adk/adkintun-reports/config.py -v $(pwd)/reports/reports:/adk/adkintun-reports/app/static/reports \ -v $(pwd)/reports/tmp:/adk/adkintun-reports/tmp -v /etc/localtime:/etc/localtime:ro --restart=unless-stopped \ --log-opt max-size=50m -m 2g -d reports-adk From 82a1edb773688d47ccb63f4291c423c351417c33 Mon Sep 17 00:00:00 2001 From: javier-op Date: Wed, 11 Oct 2017 10:52:34 -0300 Subject: [PATCH 7/8] Cambio reports/config.py --- adkintunmobile/server/reports/config.py | 33 ++++++++++++++++--------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/adkintunmobile/server/reports/config.py b/adkintunmobile/server/reports/config.py index 51ca05f..66272c7 100644 --- a/adkintunmobile/server/reports/config.py +++ b/adkintunmobile/server/reports/config.py @@ -2,7 +2,7 @@ class DefaultConfig(object): DEBUG = False TESTING = False CSRF_ENABLED = True - BIND_KEY = "frontend" + SQLALCHEMY_TRACK_MODIFICATIONS = True USER_SERVER = "this-should-be-changed" SECRET_KEY_SERVER = "this-should-be-changed" @@ -10,7 +10,7 @@ class DefaultConfig(object): DB_NAME_SERVER = "this-should-be-changed" SQLALCHEMY_DATABASE_URI = "postgresql://{}:{}@{}/{}".format(USER_SERVER, SECRET_KEY_SERVER, HOST_SERVER, DB_NAME_SERVER) - + BIND_KEY = "frontend" USER_FRONTEND = "this-should-be-changed" SECRET_KEY_FRONTEND = "this-should-be-changed" HOST_FRONTEND = "this-should-be-changed" @@ -19,25 +19,34 @@ class DefaultConfig(object): BIND_KEY: "postgresql://{}:{}@{}/{}".format(USER_FRONTEND, SECRET_KEY_FRONTEND, HOST_FRONTEND, DB_NAME_FRONTEND) } - SQLALCHEMY_TRACK_MODIFICATIONS = True class TestConfig(object): - USER = "this-should-be-changed" - SECRET_KEY = "this-should-be-changed" + TESTING = True + DEBUG = True + SQLALCHEMY_TRACK_MODIFICATIONS = True + PRESERVE_CONTEXT_ON_EXCEPTION = False + + USER_SERVER = "this-should-be-changed" + SECRET_KEY_SERVER = "this-should-be-changed" + HOST_SERVER = "this-should-be-changed" + DB_NAME_SERVER = "this-should-be-changed" + SQLALCHEMY_DATABASE_URI = "postgresql://{}:{}@{}/{}".format(USER_SERVER, SECRET_KEY_SERVER, + HOST_SERVER, DB_NAME_SERVER) BIND_KEY = "frontend" - SQLALCHEMY_DATABASE_URI = "postgresql://" + USER + ":" + SECRET_KEY + "@localhost/this-should-be-changed" + USER_FRONTEND = "this-should-be-changed" + SECRET_KEY_FRONTEND = "this-should-be-changed" + HOST_FRONTEND = "this-should-be-changed" + DB_NAME_FRONTEND = "this-should-be-changed" SQLALCHEMY_BINDS = { - BIND_KEY: "postgresql://" + USER + ":" + SECRET_KEY + "@localhost/this-should-be-changed" + BIND_KEY: "postgresql://{}:{}@{}/{}".format(USER_FRONTEND, SECRET_KEY_FRONTEND, + HOST_FRONTEND, DB_NAME_FRONTEND) } - SQLALCHEMY_TRACK_MODIFICATIONS = True - PRESERVE_CONTEXT_ON_EXCEPTION = False - TESTING = True - DEBUG = True class Files: STATIC_FILES_FOLDER = "app/static" REPORTS_FOLDER = STATIC_FILES_FOLDER + "/" + "reports" LOGS_FOLDER = "tmp" - REPORTS_LOG_FILE = "report.log" + REPORTS_LOG_FILE = "update.log" + From 1df1c5eccde364c585f9676f7525ac883c67c399 Mon Sep 17 00:00:00 2001 From: javier-op Date: Wed, 11 Oct 2017 10:56:48 -0300 Subject: [PATCH 8/8] Actualizo runcommands.txt --- adkintunmobile/server/runcommands.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/adkintunmobile/server/runcommands.txt b/adkintunmobile/server/runcommands.txt index d406681..c8c15bf 100644 --- a/adkintunmobile/server/runcommands.txt +++ b/adkintunmobile/server/runcommands.txt @@ -1,3 +1,9 @@ +cd adkintunmobile/server/reports + +docker build --no-cache reports-adk + +cd .. + docker run --name reports-adk --link postgres-adk3:postgres-adk3 --link postgres-report:postgres-report \ -v $(pwd)/reports/config.py:/adk/adkintun-reports/config.py -v $(pwd)/reports/reports:/adk/adkintun-reports/app/static/reports \ -v $(pwd)/reports/tmp:/adk/adkintun-reports/tmp -v /etc/localtime:/etc/localtime:ro --restart=unless-stopped \