Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #33

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Dev #33

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions adkintunmobile/server/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ server{
uwsgi_pass server-adk:8000;
client_max_body_size 31M;
}

}
39 changes: 39 additions & 0 deletions adkintunmobile/server/reports/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## Header
FROM python:3.5.1-slim
MAINTAINER 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

52 changes: 52 additions & 0 deletions adkintunmobile/server/reports/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
class DefaultConfig(object):
DEBUG = False
TESTING = False
CSRF_ENABLED = True
SQLALCHEMY_TRACK_MODIFICATIONS = True

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"
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://{}:{}@{}/{}".format(USER_FRONTEND, SECRET_KEY_FRONTEND,
HOST_FRONTEND, DB_NAME_FRONTEND)
}


class TestConfig(object):
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"
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://{}:{}@{}/{}".format(USER_FRONTEND, SECRET_KEY_FRONTEND,
HOST_FRONTEND, DB_NAME_FRONTEND)
}


class Files:
STATIC_FILES_FOLDER = "app/static"
REPORTS_FOLDER = STATIC_FILES_FOLDER + "/" + "reports"
LOGS_FOLDER = "tmp"
REPORTS_LOG_FILE = "update.log"

23 changes: 15 additions & 8 deletions adkintunmobile/server/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
}


Expand Down Expand Up @@ -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
}


Expand Down
14 changes: 14 additions & 0 deletions adkintunmobile/server/runcommands.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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 \
--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