From 5a67551dd45db35e1db0d6a3a5f7ac830ee266cd Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sat, 27 Jan 2018 22:26:37 +0100 Subject: [PATCH] Alpinize + Dockerize Sahana Eden --- sahana.sh | 108 +++++------------- sahana/Dockerfile | 60 ++++++++++ .../{tmp/sahana-createdb.sql => createdb.sql} | 0 .../web2py}/applications/eden/languages/cs.py | 0 .../sahana => docker/srv/web2py}/routes.py | 0 sahana/docker/usr/local/bin/web2py_eden.sh | 4 + sahana/etc/init.d/sahana | 26 +++++ sahana/etc/nginx/apps-available/sahana | 13 --- sahana/etc/nginx/conf.d/sahana.conf | 14 +++ sahana/etc/uwsgi/apps-available/sahana.ini | 15 --- .../eden/models => conf}/000_config.py | 4 +- .../eden/models => conf}/00_settings.py | 0 .../Spotter/DefaultItems.csv | 0 .../Spotter/DefaultSkillCompetency.csv | 0 .../Spotter/DefaultSkillList.csv | 0 .../Spotter/DrivingSkillList.csv | 0 .../Spotter/DrivingSkillList_EU.csv | 0 .../Spotter/LanguageCompetency.csv | 0 .../Spotter/LanguageSkillList.csv | 0 .../Spotter/StandardItems.csv | 0 .../templates => data}/Spotter/__init__.py | 0 .../templates => data}/Spotter/auth_roles.csv | 0 .../Spotter/certificate.csv | 0 .../templates => data}/Spotter/cms_post.csv | 0 .../templates => data}/Spotter/config.py | 0 .../templates => data}/Spotter/css.cfg | 0 .../Spotter/dvr_case_status.csv | 0 .../templates => data}/Spotter/event_type.csv | 0 .../templates => data}/Spotter/gis_config.csv | 0 .../Spotter/gis_hierarchy.csv | 0 .../Spotter/gis_layer_bing.csv | 0 .../Spotter/gis_layer_coordinate.csv | 0 .../Spotter/gis_layer_feature.csv | 0 .../Spotter/gis_layer_geojson.csv | 0 .../Spotter/gis_layer_georss.csv | 0 .../Spotter/gis_layer_google.csv | 0 .../Spotter/gis_layer_mgrs.csv | 0 .../Spotter/gis_layer_openstreetmap.csv | 0 .../Spotter/gis_layer_openweathermap.csv | 0 .../Spotter/gis_layer_tms.csv | 0 .../Spotter/gis_layer_wms.csv | 0 .../templates => data}/Spotter/gis_marker.csv | 0 .../Spotter/incident_type.csv | 0 .../templates => data}/Spotter/layouts.py | 0 .../templates => data}/Spotter/maintenance.py | 0 .../Spotter/masterUsers.csv | 0 .../Spotter/membership_type.csv | 0 .../templates => data}/Spotter/menus.py | 0 .../Spotter/office_type.csv | 0 .../templates => data}/Spotter/org_sector.csv | 0 .../Spotter/organisation_type.csv | 0 .../templates => data}/Spotter/parser.py | 0 .../Spotter/project_activity_type.csv | 0 .../Spotter/project_beneficiary_type.csv | 0 .../Spotter/project_hazard.csv | 0 .../Spotter/project_status.csv | 0 .../Spotter/project_theme.csv | 0 .../Spotter/shelter_type.csv | 0 .../templates => data}/Spotter/tasks.cfg | 0 .../templates => data}/Spotter/tests.py | 0 .../Spotter/views/footer.html | 0 .../Spotter/views/layout.html | 0 .../Spotter/work_job_type.csv | 0 sahana/srv/sahana/run_scheduler.py | 6 - 64 files changed, 135 insertions(+), 115 deletions(-) create mode 100644 sahana/Dockerfile rename sahana/{tmp/sahana-createdb.sql => createdb.sql} (100%) rename sahana/{srv/sahana => docker/srv/web2py}/applications/eden/languages/cs.py (100%) rename sahana/{srv/sahana => docker/srv/web2py}/routes.py (100%) create mode 100755 sahana/docker/usr/local/bin/web2py_eden.sh create mode 100755 sahana/etc/init.d/sahana delete mode 100644 sahana/etc/nginx/apps-available/sahana create mode 100644 sahana/etc/nginx/conf.d/sahana.conf delete mode 100644 sahana/etc/uwsgi/apps-available/sahana.ini rename sahana/srv/sahana/{applications/eden/models => conf}/000_config.py (99%) rename sahana/srv/sahana/{applications/eden/models => conf}/00_settings.py (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/DefaultItems.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/DefaultSkillCompetency.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/DefaultSkillList.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/DrivingSkillList.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/DrivingSkillList_EU.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/LanguageCompetency.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/LanguageSkillList.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/StandardItems.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/__init__.py (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/auth_roles.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/certificate.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/cms_post.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/config.py (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/css.cfg (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/dvr_case_status.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/event_type.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/gis_config.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/gis_hierarchy.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/gis_layer_bing.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/gis_layer_coordinate.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/gis_layer_feature.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/gis_layer_geojson.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/gis_layer_georss.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/gis_layer_google.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/gis_layer_mgrs.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/gis_layer_openstreetmap.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/gis_layer_openweathermap.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/gis_layer_tms.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/gis_layer_wms.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/gis_marker.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/incident_type.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/layouts.py (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/maintenance.py (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/masterUsers.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/membership_type.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/menus.py (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/office_type.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/org_sector.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/organisation_type.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/parser.py (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/project_activity_type.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/project_beneficiary_type.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/project_hazard.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/project_status.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/project_theme.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/shelter_type.csv (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/tasks.cfg (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/tests.py (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/views/footer.html (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/views/layout.html (100%) rename sahana/srv/sahana/{applications/eden/modules/templates => data}/Spotter/work_job_type.csv (100%) delete mode 100644 sahana/srv/sahana/run_scheduler.py diff --git a/sahana.sh b/sahana.sh index 07a7cf7..90fb366 100755 --- a/sahana.sh +++ b/sahana.sh @@ -1,102 +1,52 @@ -#!/bin/bash +#!/bin/sh SOURCE_DIR=$(realpath $(dirname "${0}"))/sahana -# Install dependencies for Sahana -apt-get -y --no-install-recommends install python-dateutil python-imaging python-lxml python-matplotlib python-openid python-psycopg2 python-pyth python-reportlab python-requests python-shapely python-tweepy python-xlrd python-xlwt +# Check prerequisites +docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh -# Install web2py -git clone --recursive https://github.com/web2py/web2py.git /srv/sahana -git -C /srv/sahana checkout cda35fd -git -C /srv/sahana submodule update - -# Install Sahana -git clone --depth 1 https://github.com/sahana/eden.git /srv/sahana/applications/eden - -# Install TwitterSearch 0.78.6 -git clone --depth 1 https://github.com/ckoepp/TwitterSearch.git /tmp/TwitterSearch -cd /tmp/TwitterSearch -python setup.py install -cd - -rm -rf /tmp/TwitterSearch - -# Copy Czech language file -cp ${SOURCE_DIR}/srv/sahana/applications/eden/languages/cs.py /srv/sahana/applications/eden/languages/cs.py - -# Symlink fonts with Czech glyphs -ln -s /usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf /srv/sahana/applications/eden/static/fonts/DejaVuSerif-Bold.ttf -ln -s /usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf /srv/sahana/applications/eden/static/fonts/DejaVuSerif.ttf +# Build Docker container +docker build -t sahana ${SOURCE_DIR} # Create PostgreSQL user and database export SAHANA_PWD=$(head -c 18 /dev/urandom | base64) -envsubst <${SOURCE_DIR}/tmp/sahana-createdb.sql >/tmp/sahana-createdb.sql -sudo -u postgres psql -f /tmp/sahana-createdb.sql -rm -f /tmp/sahana-createdb.sql +envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql -# Configure web2py -rm -rf /srv/sahana/applications/{admin,examples,welcome} -cp ${SOURCE_DIR}/srv/sahana/routes.py /srv/sahana/routes.py -cp ${SOURCE_DIR}/srv/sahana/run_scheduler.py /srv/sahana/run_scheduler.py -ln -s /srv/sahana/handlers/wsgihandler.py /srv/sahana/wsgihandler.py +# Prepare persistent directory structure +mkdir -p /srv/sahana/conf /srv/sahana/data/databases /srv/sahana/data/uploads +chown -R 8001:8001 /srv/sahana/conf +docker run --rm -v /srv/sahana/conf:/mnt/conf sahana cp -rp /srv/web2py/applications/eden/models/. /mnt/conf + +# Copy Spotter template +cp -r ${SOURCE_DIR}/srv/sahana/data/Spotter /srv/sahana/data/ +chown -R 8001:8001 /srv/sahana/data # Configure Sahana -mkdir /srv/sahana/applications/eden/{databases,errors,sessions} -mkdir -p /srv/sahana/applications/eden/static/cache/chart -mkdir -p /srv/sahana/applications/eden/uploads/{gis_cache,images,tracks} export SAHANA_HMAC=$(head -c 18 /dev/urandom | base64) -envsubst <${SOURCE_DIR}/srv/sahana/applications/eden/models/000_config.py >/srv/sahana/applications/eden/models/000_config.py -cp ${SOURCE_DIR}/srv/sahana/applications/eden/models/00_settings.py /srv/sahana/applications/eden/models/00_settings.py +envsubst <${SOURCE_DIR}/srv/sahana/conf/000_config.py >/srv/sahana/conf/000_config.py +cp ${SOURCE_DIR}/srv/sahana/conf/00_settings.py /srv/sahana/conf/00_settings.py export SAHANA_ADMIN_USER=admin@example.com export SAHANA_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) -cp -r ${SOURCE_DIR}/srv/sahana/applications/eden/modules/templates/Spotter /srv/sahana/applications/eden/modules/templates/ -envsubst <${SOURCE_DIR}/srv/sahana/applications/eden/modules/templates/Spotter/masterUsers.csv >/srv/sahana/applications/eden/modules/templates/Spotter/masterUsers.csv - -# Create OS user -adduser --system --group --home /srv/sahana --shell /bin/false sahana -chown -R sahana:sahana /srv/sahana +envsubst <${SOURCE_DIR}/srv/sahana/data/Spotter/masterUsers.csv >/srv/sahana/data/Spotter/masterUsers.csv # Populate database -cd /srv/sahana -sudo -u sahana python web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py +docker run --rm -h sahana --link postgres -v /srv/sahana/conf:/srv/web2py/applications/eden/models -v /srv/sahana/data/Spotter:/srv/web2py/applications/eden/modules/templates/Spotter -v /srv/sahana/data/databases:/srv/web2py/applications/eden/databases sahana ./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py # Set "production values" (increases performance) only if the DEBUG environment variable is not set if [ ${DEBUG:-0} -eq 0 ]; then - sed -i 's/settings.base.migrate = True/settings.base.migrate = False/' /srv/sahana/applications/eden/models/000_config.py - sed -i 's/settings.base.debug = True/settings.base.debug = False/' /srv/sahana/applications/eden/models/000_config.py - sed -i 's/#settings.base.prepopulate = 0/settings.base.prepopulate = 0/' /srv/sahana/applications/eden/models/000_config.py - sudo -u sahana python web2py.py -S eden -M -R applications/eden/static/scripts/tools/compile.py + sed -i 's/settings.base.migrate = True/settings.base.migrate = False/' /srv/sahana/conf/000_config.py + sed -i 's/settings.base.debug = True/settings.base.debug = False/' /srv/sahana/conf/000_config.py + sed -i 's/#settings.base.prepopulate = 0/settings.base.prepopulate = 0/' /srv/sahana/conf/000_config.py fi -# Create uwsgi and nginx app definition -cp ${SOURCE_DIR}/etc/uwsgi/apps-available/sahana.ini /etc/uwsgi/apps-available/sahana.ini -ln -s /etc/uwsgi/apps-available/sahana.ini /etc/uwsgi/apps-enabled/sahana.ini -cp ${SOURCE_DIR}/etc/nginx/apps-available/sahana /etc/nginx/apps-available/sahana -ln -s /etc/nginx/apps-available/sahana /etc/nginx/apps-enabled/sahana +# Create Sahana service +cp ${SOURCE_DIR}/etc/init.d/sahana /etc/init.d/sahana +rc-update add sahana boot +service sahana start -# Restart services -systemctl restart uwsgi -systemctl restart nginx +# Create nginx app definition +cp ${SOURCE_DIR}/etc/nginx/conf.d/sahana.conf /etc/nginx/conf.d/sahana.conf +service nginx reload # Add portal application definition -portal-app-manager sahana-eden "/eden/" "${SAHANA_ADMIN_USER}" "${SAHANA_ADMIN_PWD}" - -# TODO: Does matplotlib still require MPLCONFIGDIR directory? -# If so, /srv/sahana/wsgihandler.py needs to be modified - -# TODO: Potentially needed dependencies -# WARNING: Setup unresolved dependency: boto required for Setup Module -# WARNING: S3Doc unresolved dependency: sunburnt required for Full-Text Search support -# WARNING: S3GIS unresolved dependency: selenium required for Map printing support -# WARNING: Setup unresolved dependency: PyYAML required for Setup Module -# WARNING: S3GIS unresolved dependency: GDAL required for Shapefile support -# WARNING: Setup unresolved dependency: ansible required for Setup Module -# WARNING: Survey unresolved dependency: PyRTF required if you want to export assessment/survey templates as a Word document -# WARNING: Unresolved optional dependency: pyserial required -# WARNING: Message Parsing unresolved dependency: TwitterSearch required for fetching results from twitter keyword queries - -# TODO: Development notes -# vi /srv/sahana/applications/eden/modules/templates/default/config.py -# vi /srv/sahana/applications/eden/modules/s3cfg.py -# sudo -u sahana /srv/sahana/web2py.py -i 192.168.2.202 -a sahana --nogui -# sudo -u sahana openssl req -new -x509 -nodes -out /srv/sahana/cert.pem -keyout /srv/sahana/cert.key -subj "/C=CZ/CN=$(hostname -f)" -# sudo -u sahana /srv/sahana/web2py.py -i 192.168.2.202 -a sahana -c /srv/sahana/cert.pem -k /srv/sahana/cert.key --nogui +portal-app-manager sahana-eden "https://{host}:8401/eden/" "${SAHANA_ADMIN_USER}" "${SAHANA_ADMIN_PWD}" diff --git a/sahana/Dockerfile b/sahana/Dockerfile new file mode 100644 index 0000000..177139d --- /dev/null +++ b/sahana/Dockerfile @@ -0,0 +1,60 @@ +FROM alpine:3.7 +MAINTAINER Disassembler + +RUN \ + # Install Python2 runtime + apk --no-cache add python2 + +RUN \ + # Install runtime XML dependencies + apk --no-cache add libxml2 libxslt + +RUN \ + # Install runtime dependencies + apk --no-cache add py2-dateutil py2-lxml py2-numpy py2-pillow py2-psycopg2 py2-requests \ + && echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >>/etc/apk/repositories \ + && apk --no-cache add geos py-gdal \ + && sed -i '$ d' /etc/apk/repositories + +RUN \ + # Install build dependencies + apk --no-cache add --virtual .deps build-base git freetype-dev libpng-dev py-numpy-dev py2-pip python2-dev ttf-dejavu \ + # Hackfix for python find_library('c') call + && ln -s /lib/ld-musl-x86_64.so.1 /lib/libc.so.1 \ + # Install web2py + && git clone --recursive https://github.com/web2py/web2py.git /srv/web2py \ + && git -C /srv/web2py checkout 7035398 \ + && git -C /srv/web2py submodule update \ + # Fix Web2py urllib import (https://github.com/web2py/pydal/commit/9d2290c) + && sed -i 's/import traceback/import traceback\nimport urllib/' /srv/web2py/gluon/packages/dal/pydal/base.py \ + # Install Sahana + && git clone --depth 1 https://github.com/sahana/eden.git /srv/web2py/applications/eden \ + # Install python dependencies, exclude old or unnecessary ones + && sed -i 's/^ansible/#ansible/' /srv/web2py/applications/eden/optional_requirements.txt \ + && sed -i 's/^boto/#boto/' /srv/web2py/applications/eden/optional_requirements.txt \ + && sed -i 's/^PIL/#PIL/' /srv/web2py/applications/eden/optional_requirements.txt \ + && sed -i 's/^PyRTF/#PyRTF/' /srv/web2py/applications/eden/optional_requirements.txt \ + && sed -i 's/^PyYAML/#PyYAML/' /srv/web2py/applications/eden/optional_requirements.txt \ + && pip install -r /srv/web2py/applications/eden/optional_requirements.txt \ + # Copy fonts with Czech glyphs + && cp /usr/share/fonts/ttf-dejavu/DejaVuSerif-Bold.ttf /srv/web2py/applications/eden/static/fonts/DejaVuSerif-Bold.ttf \ + && cp /usr/share/fonts/ttf-dejavu/DejaVuSerif.ttf /srv/web2py/applications/eden/static/fonts/DejaVuSerif.ttf \ + # Create OS user + && addgroup -S -g 8001 sahana \ + && adduser -S -u 8001 -h /srv/web2py -s /bin/false -g sahana -G sahana sahana \ + && chown -R sahana:sahana /srv/web2py \ + # Cleanup + && apk del .deps \ + && find /srv/web2py -name '.git*' -exec rm -rf {} + \ + && rm -r /srv/web2py/applications/admin /srv/web2py/applications/examples /srv/web2py/applications/welcome \ + && rm -r /root/.cache + +COPY --chown=8001:8001 docker/srv/ /srv/ +COPY docker/usr/ /usr/ + +VOLUME ["/srv/web2py/applications/eden/models", "/srv/web2py/applications/eden/databases", "/srv/web2py/applications/eden/uploads"] +EXPOSE 8001 + +USER sahana +WORKDIR /srv/web2py +CMD ["web2py_eden.sh"] diff --git a/sahana/tmp/sahana-createdb.sql b/sahana/createdb.sql similarity index 100% rename from sahana/tmp/sahana-createdb.sql rename to sahana/createdb.sql diff --git a/sahana/srv/sahana/applications/eden/languages/cs.py b/sahana/docker/srv/web2py/applications/eden/languages/cs.py similarity index 100% rename from sahana/srv/sahana/applications/eden/languages/cs.py rename to sahana/docker/srv/web2py/applications/eden/languages/cs.py diff --git a/sahana/srv/sahana/routes.py b/sahana/docker/srv/web2py/routes.py similarity index 100% rename from sahana/srv/sahana/routes.py rename to sahana/docker/srv/web2py/routes.py diff --git a/sahana/docker/usr/local/bin/web2py_eden.sh b/sahana/docker/usr/local/bin/web2py_eden.sh new file mode 100755 index 0000000..d04a807 --- /dev/null +++ b/sahana/docker/usr/local/bin/web2py_eden.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cd /srv/web2py +./web2py.py -a $(head -c 18 /dev/urandom | base64) -K eden -X -i 0.0.0.0 -p 8001 --nogui diff --git a/sahana/etc/init.d/sahana b/sahana/etc/init.d/sahana new file mode 100755 index 0000000..9955b34 --- /dev/null +++ b/sahana/etc/init.d/sahana @@ -0,0 +1,26 @@ +#!/sbin/openrc-run + +description="Sahana Eden docker container" + +depend() { + need docker net + use dns logger netmount + after postgres +} + +start() { + /usr/bin/docker run -d --rm \ + --name sahana \ + -h sahana \ + --link postgres \ + -p 127.0.0.1:9001:8001 \ + -v /srv/sahana/conf:/srv/web2py/applications/eden/models \ + -v /srv/sahana/data/Spotter:/srv/web2py/applications/eden/modules/templates/Spotter \ + -v /srv/sahana/data/databases:/srv/web2py/applications/eden/databases \ + -v /srv/sahana/data/uploads:/srv/web2py/applications/eden/uploads \ + sahana +} + +stop() { + /usr/bin/docker stop sahana +} diff --git a/sahana/etc/nginx/apps-available/sahana b/sahana/etc/nginx/apps-available/sahana deleted file mode 100644 index 7d1b488..0000000 --- a/sahana/etc/nginx/apps-available/sahana +++ /dev/null @@ -1,13 +0,0 @@ -location /eden { - uwsgi_pass unix:///run/uwsgi/app/sahana/socket; - uwsgi_read_timeout 300s; - uwsgi_send_timeout 300s; - include uwsgi_params; - uwsgi_param UWSGI_SCHEME $scheme; - uwsgi_param SERVER_SOFTWARE nginx/$nginx_version; -} - -location ~* /eden/static { - root /srv/sahana/applications; - expires max; -} diff --git a/sahana/etc/nginx/conf.d/sahana.conf b/sahana/etc/nginx/conf.d/sahana.conf new file mode 100644 index 0000000..a164ac2 --- /dev/null +++ b/sahana/etc/nginx/conf.d/sahana.conf @@ -0,0 +1,14 @@ +server { + listen [::]:8001 ipv6only=off; + listen [::]:8401 ssl http2 ipv6only=off; + + access_log /var/log/nginx/sahana.access.log; + error_log /var/log/nginx/sahana.error.log; + + location / { + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Host $host:$server_port; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://127.0.0.1:9001; + } +} diff --git a/sahana/etc/uwsgi/apps-available/sahana.ini b/sahana/etc/uwsgi/apps-available/sahana.ini deleted file mode 100644 index c4af00f..0000000 --- a/sahana/etc/uwsgi/apps-available/sahana.ini +++ /dev/null @@ -1,15 +0,0 @@ -[uwsgi] -uid = sahana -gid = sahana -chown-socket = www-data:www-data -chdir = /srv/sahana -module = wsgihandler -cheaper = 1 -cheaper-algo = spare -cheaper-initial = 1 -cheaper-step = 1 -workers = 4 -idle = 600 -harakiri = 300 -mule = run_scheduler.py -cron = 10 -1 -1 -1 -1 python web2py.py -Q -S eden -M -R scripts/sessions2trash.py -A -o diff --git a/sahana/srv/sahana/applications/eden/models/000_config.py b/sahana/srv/sahana/conf/000_config.py similarity index 99% rename from sahana/srv/sahana/applications/eden/models/000_config.py rename to sahana/srv/sahana/conf/000_config.py index 1a54c9c..2bb6f01 100644 --- a/sahana/srv/sahana/applications/eden/models/000_config.py +++ b/sahana/srv/sahana/conf/000_config.py @@ -30,7 +30,7 @@ settings.base.template = "Spotter" settings.database.db_type = "postgres" #settings.database.db_type = "mysql" # Uncomment to use a different host -#settings.database.host = "localhost" +settings.database.host = "postgres" # Uncomment to use a different port #settings.database.port = 3306 #settings.database.port = 5432 @@ -92,7 +92,7 @@ settings.auth.hmac_key = "${SAHANA_HMAC}" # Email settings # Outbound server -settings.mail.server = "127.0.0.1:25" +settings.mail.server = "postfix:587" #settings.mail.tls = True # Useful for Windows Laptops: # https://www.google.com/settings/security/lesssecureapps diff --git a/sahana/srv/sahana/applications/eden/models/00_settings.py b/sahana/srv/sahana/conf/00_settings.py similarity index 100% rename from sahana/srv/sahana/applications/eden/models/00_settings.py rename to sahana/srv/sahana/conf/00_settings.py diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/DefaultItems.csv b/sahana/srv/sahana/data/Spotter/DefaultItems.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/DefaultItems.csv rename to sahana/srv/sahana/data/Spotter/DefaultItems.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/DefaultSkillCompetency.csv b/sahana/srv/sahana/data/Spotter/DefaultSkillCompetency.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/DefaultSkillCompetency.csv rename to sahana/srv/sahana/data/Spotter/DefaultSkillCompetency.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/DefaultSkillList.csv b/sahana/srv/sahana/data/Spotter/DefaultSkillList.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/DefaultSkillList.csv rename to sahana/srv/sahana/data/Spotter/DefaultSkillList.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/DrivingSkillList.csv b/sahana/srv/sahana/data/Spotter/DrivingSkillList.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/DrivingSkillList.csv rename to sahana/srv/sahana/data/Spotter/DrivingSkillList.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/DrivingSkillList_EU.csv b/sahana/srv/sahana/data/Spotter/DrivingSkillList_EU.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/DrivingSkillList_EU.csv rename to sahana/srv/sahana/data/Spotter/DrivingSkillList_EU.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/LanguageCompetency.csv b/sahana/srv/sahana/data/Spotter/LanguageCompetency.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/LanguageCompetency.csv rename to sahana/srv/sahana/data/Spotter/LanguageCompetency.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/LanguageSkillList.csv b/sahana/srv/sahana/data/Spotter/LanguageSkillList.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/LanguageSkillList.csv rename to sahana/srv/sahana/data/Spotter/LanguageSkillList.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/StandardItems.csv b/sahana/srv/sahana/data/Spotter/StandardItems.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/StandardItems.csv rename to sahana/srv/sahana/data/Spotter/StandardItems.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/__init__.py b/sahana/srv/sahana/data/Spotter/__init__.py similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/__init__.py rename to sahana/srv/sahana/data/Spotter/__init__.py diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/auth_roles.csv b/sahana/srv/sahana/data/Spotter/auth_roles.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/auth_roles.csv rename to sahana/srv/sahana/data/Spotter/auth_roles.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/certificate.csv b/sahana/srv/sahana/data/Spotter/certificate.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/certificate.csv rename to sahana/srv/sahana/data/Spotter/certificate.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/cms_post.csv b/sahana/srv/sahana/data/Spotter/cms_post.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/cms_post.csv rename to sahana/srv/sahana/data/Spotter/cms_post.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/config.py b/sahana/srv/sahana/data/Spotter/config.py similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/config.py rename to sahana/srv/sahana/data/Spotter/config.py diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/css.cfg b/sahana/srv/sahana/data/Spotter/css.cfg similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/css.cfg rename to sahana/srv/sahana/data/Spotter/css.cfg diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/dvr_case_status.csv b/sahana/srv/sahana/data/Spotter/dvr_case_status.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/dvr_case_status.csv rename to sahana/srv/sahana/data/Spotter/dvr_case_status.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/event_type.csv b/sahana/srv/sahana/data/Spotter/event_type.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/event_type.csv rename to sahana/srv/sahana/data/Spotter/event_type.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_config.csv b/sahana/srv/sahana/data/Spotter/gis_config.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_config.csv rename to sahana/srv/sahana/data/Spotter/gis_config.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_hierarchy.csv b/sahana/srv/sahana/data/Spotter/gis_hierarchy.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_hierarchy.csv rename to sahana/srv/sahana/data/Spotter/gis_hierarchy.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_bing.csv b/sahana/srv/sahana/data/Spotter/gis_layer_bing.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_bing.csv rename to sahana/srv/sahana/data/Spotter/gis_layer_bing.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_coordinate.csv b/sahana/srv/sahana/data/Spotter/gis_layer_coordinate.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_coordinate.csv rename to sahana/srv/sahana/data/Spotter/gis_layer_coordinate.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_feature.csv b/sahana/srv/sahana/data/Spotter/gis_layer_feature.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_feature.csv rename to sahana/srv/sahana/data/Spotter/gis_layer_feature.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_geojson.csv b/sahana/srv/sahana/data/Spotter/gis_layer_geojson.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_geojson.csv rename to sahana/srv/sahana/data/Spotter/gis_layer_geojson.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_georss.csv b/sahana/srv/sahana/data/Spotter/gis_layer_georss.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_georss.csv rename to sahana/srv/sahana/data/Spotter/gis_layer_georss.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_google.csv b/sahana/srv/sahana/data/Spotter/gis_layer_google.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_google.csv rename to sahana/srv/sahana/data/Spotter/gis_layer_google.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_mgrs.csv b/sahana/srv/sahana/data/Spotter/gis_layer_mgrs.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_mgrs.csv rename to sahana/srv/sahana/data/Spotter/gis_layer_mgrs.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_openstreetmap.csv b/sahana/srv/sahana/data/Spotter/gis_layer_openstreetmap.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_openstreetmap.csv rename to sahana/srv/sahana/data/Spotter/gis_layer_openstreetmap.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_openweathermap.csv b/sahana/srv/sahana/data/Spotter/gis_layer_openweathermap.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_openweathermap.csv rename to sahana/srv/sahana/data/Spotter/gis_layer_openweathermap.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_tms.csv b/sahana/srv/sahana/data/Spotter/gis_layer_tms.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_tms.csv rename to sahana/srv/sahana/data/Spotter/gis_layer_tms.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_wms.csv b/sahana/srv/sahana/data/Spotter/gis_layer_wms.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_layer_wms.csv rename to sahana/srv/sahana/data/Spotter/gis_layer_wms.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_marker.csv b/sahana/srv/sahana/data/Spotter/gis_marker.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/gis_marker.csv rename to sahana/srv/sahana/data/Spotter/gis_marker.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/incident_type.csv b/sahana/srv/sahana/data/Spotter/incident_type.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/incident_type.csv rename to sahana/srv/sahana/data/Spotter/incident_type.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/layouts.py b/sahana/srv/sahana/data/Spotter/layouts.py similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/layouts.py rename to sahana/srv/sahana/data/Spotter/layouts.py diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/maintenance.py b/sahana/srv/sahana/data/Spotter/maintenance.py similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/maintenance.py rename to sahana/srv/sahana/data/Spotter/maintenance.py diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/masterUsers.csv b/sahana/srv/sahana/data/Spotter/masterUsers.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/masterUsers.csv rename to sahana/srv/sahana/data/Spotter/masterUsers.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/membership_type.csv b/sahana/srv/sahana/data/Spotter/membership_type.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/membership_type.csv rename to sahana/srv/sahana/data/Spotter/membership_type.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/menus.py b/sahana/srv/sahana/data/Spotter/menus.py similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/menus.py rename to sahana/srv/sahana/data/Spotter/menus.py diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/office_type.csv b/sahana/srv/sahana/data/Spotter/office_type.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/office_type.csv rename to sahana/srv/sahana/data/Spotter/office_type.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/org_sector.csv b/sahana/srv/sahana/data/Spotter/org_sector.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/org_sector.csv rename to sahana/srv/sahana/data/Spotter/org_sector.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/organisation_type.csv b/sahana/srv/sahana/data/Spotter/organisation_type.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/organisation_type.csv rename to sahana/srv/sahana/data/Spotter/organisation_type.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/parser.py b/sahana/srv/sahana/data/Spotter/parser.py similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/parser.py rename to sahana/srv/sahana/data/Spotter/parser.py diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/project_activity_type.csv b/sahana/srv/sahana/data/Spotter/project_activity_type.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/project_activity_type.csv rename to sahana/srv/sahana/data/Spotter/project_activity_type.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/project_beneficiary_type.csv b/sahana/srv/sahana/data/Spotter/project_beneficiary_type.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/project_beneficiary_type.csv rename to sahana/srv/sahana/data/Spotter/project_beneficiary_type.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/project_hazard.csv b/sahana/srv/sahana/data/Spotter/project_hazard.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/project_hazard.csv rename to sahana/srv/sahana/data/Spotter/project_hazard.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/project_status.csv b/sahana/srv/sahana/data/Spotter/project_status.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/project_status.csv rename to sahana/srv/sahana/data/Spotter/project_status.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/project_theme.csv b/sahana/srv/sahana/data/Spotter/project_theme.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/project_theme.csv rename to sahana/srv/sahana/data/Spotter/project_theme.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/shelter_type.csv b/sahana/srv/sahana/data/Spotter/shelter_type.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/shelter_type.csv rename to sahana/srv/sahana/data/Spotter/shelter_type.csv diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/tasks.cfg b/sahana/srv/sahana/data/Spotter/tasks.cfg similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/tasks.cfg rename to sahana/srv/sahana/data/Spotter/tasks.cfg diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/tests.py b/sahana/srv/sahana/data/Spotter/tests.py similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/tests.py rename to sahana/srv/sahana/data/Spotter/tests.py diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/views/footer.html b/sahana/srv/sahana/data/Spotter/views/footer.html similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/views/footer.html rename to sahana/srv/sahana/data/Spotter/views/footer.html diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/views/layout.html b/sahana/srv/sahana/data/Spotter/views/layout.html similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/views/layout.html rename to sahana/srv/sahana/data/Spotter/views/layout.html diff --git a/sahana/srv/sahana/applications/eden/modules/templates/Spotter/work_job_type.csv b/sahana/srv/sahana/data/Spotter/work_job_type.csv similarity index 100% rename from sahana/srv/sahana/applications/eden/modules/templates/Spotter/work_job_type.csv rename to sahana/srv/sahana/data/Spotter/work_job_type.csv diff --git a/sahana/srv/sahana/run_scheduler.py b/sahana/srv/sahana/run_scheduler.py deleted file mode 100644 index d6e5dbd..0000000 --- a/sahana/srv/sahana/run_scheduler.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env python - -from gluon.shell import run - -if __name__ == '__main__': - run('eden', True, True, None, False, 'from gluon import current; current._scheduler.loop()')