From a4ea3c15b60ce09d5a28597c4495d784ae547e7f Mon Sep 17 00:00:00 2001 From: derchris Date: Tue, 17 Jul 2018 15:41:02 +0200 Subject: [PATCH 1/2] add docker setup --- Dockerfile | 9 +++++++++ INSTALL.md | 21 +++++++++++++++++++++ init.sh | 4 ++++ requirements.txt | 1 + start.sh | 15 +++++++++++++++ 5 files changed, 50 insertions(+) create mode 100644 Dockerfile create mode 100755 init.sh create mode 100755 start.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e8e77d9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:2.7 +RUN apt update +RUN apt upgrade -y +RUN apt install vim -y +RUN mkdir /sabot +WORKDIR /sabot +ADD . /sabot +RUN pip install -r requirements.txt +EXPOSE 8000 diff --git a/INSTALL.md b/INSTALL.md index 3855e1e..cbef8e9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -48,3 +48,24 @@ If you want to use the invoice creation functionality, it is required that you have libreoffice (or openoffice) installed on the server. Here is a pretty good tutorial to run django apps with guniocorn behind an apache webserver: https://wiki.uberspace.de/cool:django (easy to adopt for SaBoT) + +## Docker Setup + +You can also run the server instance inside a Docker container + +- create the following config files: + - sabot/settings.py + - sabot/conferenceSettings.py + - sabot/localSettings.py (and sabot/prodSettings.py if you want to distinguish a development and a production version) from their example files (prodSettings.py needs the same parameters) + - Make sure that `PROJECT_ROOT = '/sabot'` is set in sabot/localSettings.py (or sabot/prodSettings.py) +- create the Docker image + - docker build -t sabot:latest . +- create a container with that image + - docker run -it -p 8000:8000 sabot bash +- run the following scripts to initialize and run the server + - ./init.sh + - ./start.sh + +If all was going well you should see the gunicorn server starting up and some logs lines +Open your webbrowser and go to http://localhost:8000 + diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..8c0beb1 --- /dev/null +++ b/init.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +./manage.py migrate +./manage.py createsuperuser diff --git a/requirements.txt b/requirements.txt index b2bfb5e..a8cf776 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ python-rtkit>=0.7.0 requests>=2.12 lxml>=3.7.2 Pillow>=4.0.0 +gunicorn==19.9.0 diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..251ba9f --- /dev/null +++ b/start.sh @@ -0,0 +1,15 @@ +#!/bin/bash +touch gunicorn.log +touch access.log + +tail -n 0 -f *.log & + +echo Starting Gunicorn. +exec gunicorn sabot.wsgi:application \ + --bind 0.0.0.0:8000 \ + --name sabot \ + --workers 3 \ + --log-level=info \ + --log-file=/sabot/gunicorn.log \ + --access-logfile=/sabot/access.log \ + "$@" From 743db1f8f4ce15b2705dbafaa1cb22e08b88a0ac Mon Sep 17 00:00:00 2001 From: derchris Date: Tue, 17 Jul 2018 15:44:53 +0200 Subject: [PATCH 2/2] missing space --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index cbef8e9..ba05819 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -66,6 +66,6 @@ You can also run the server instance inside a Docker container - ./init.sh - ./start.sh -If all was going well you should see the gunicorn server starting up and some logs lines +If all was going well you should see the gunicorn server starting up and some logs lines Open your webbrowser and go to http://localhost:8000