From b804987254e28547ed319f3e52262aaa55ef5bee Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sun, 22 Mar 2020 19:50:18 +0100 Subject: [PATCH] Make Sahana SPOC-compatible --- lxc-apps/sahana/app | 29 +++++++++++++++++ lxc-apps/sahana/image | 9 +++--- lxc-apps/sahana/install.sh | 63 +++++++++++------------------------- lxc-apps/sahana/meta | 29 ----------------- lxc-apps/sahana/uninstall.sh | 2 +- lxc-apps/sambro/install.sh | 8 ++--- 6 files changed, 55 insertions(+), 85 deletions(-) create mode 100644 lxc-apps/sahana/app delete mode 100644 lxc-apps/sahana/meta diff --git a/lxc-apps/sahana/app b/lxc-apps/sahana/app new file mode 100644 index 0000000..0a58268 --- /dev/null +++ b/lxc-apps/sahana/app @@ -0,0 +1,29 @@ +{ + "version": "0.0.1-200313", + "meta": { + "title": "Sahana Eden", + "desc-cs": "Řízení humanítární činnosti", + "desc-en": "Management of humanitarian activities", + "license": "GPL" + }, + "containers": { + "sahana": { + "image": "sahana_0.0.1-200313", + "depends": [ + "sahana-postgres" + ], + "mounts": { + "sahana/sahana_conf": "srv/web2py/applications/eden/models", + "sahana/sahana_data/Spotter": "srv/web2py/applications/eden/modules/templates/Spotter", + "sahana/sahana_data/databases": "srv/web2py/applications/eden/databases", + "sahana/sahana_data/uploads": "srv/web2py/applications/eden/uploads" + } + }, + "sahana-postgres": { + "image": "postgis_3.0.0-200313", + "mounts": { + "sahana/postgres_data": "/var/lib/postgresql" + } + } + } +} diff --git a/lxc-apps/sahana/image b/lxc-apps/sahana/image index 22fc03e..000f6e3 100644 --- a/lxc-apps/sahana/image +++ b/lxc-apps/sahana/image @@ -1,5 +1,5 @@ -IMAGE sahana_0.0.1-200207 -FROM alpine3.11-python3.8_3.8.1-200207 +IMAGE sahana_0.0.1-200313 +FROM alpine3.11-python3.8_3.8.2-200313 RUN EOF # Install runtime dependencies @@ -37,8 +37,8 @@ COPY image.d RUN EOF # Create OS user - addgroup -S sahana - adduser -S -h /srv/web2py -s /bin/false -g sahana -G sahana sahana + addgroup -S -g 8080 sahana + adduser -S -u 8080 -h /srv/web2py -s /bin/false -g sahana -G sahana sahana chown -R sahana:sahana /srv/web2py # Patch web2py for python 3.8 @@ -48,7 +48,6 @@ RUN EOF # Cleanup apk --no-cache 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 rm /tmp/python38.patch EOF diff --git a/lxc-apps/sahana/install.sh b/lxc-apps/sahana/install.sh index cc84991..b9fcaa4 100755 --- a/lxc-apps/sahana/install.sh +++ b/lxc-apps/sahana/install.sh @@ -1,39 +1,18 @@ #!/bin/sh set -ev -# Create containers -spoc-container create \ - -m sahana/postgres_data:var/lib/postgresql \ - sahana-postgres postgis_3.0.0-200207 -spoc-container create \ - -d sahana-postgres \ - -m sahana/sahana_conf:srv/web2py/applications/eden/models \ - -m sahana/sahana_data/Spotter:srv/web2py/applications/eden/modules/templates/Spotter \ - -m sahana/sahana_data/databases:srv/web2py/applications/eden/databases \ - -m sahana/sahana_data/uploads:srv/web2py/applications/eden/uploads \ - sahana sahana_0.0.1-200207 - -# TODO: Populate from spoc -LAYER_DIR="/var/lib/spoc/layers" -VOLUME_DIR="/var/lib/spoc/volumes/sahana" -POSTGRES_UID=70 -POSTGRES_GID=70 -POSTGRES_NSUID=100070 -POSTGRES_NSGID=100070 -SAHANA_UID=103 -SAHANA_GID=104 -SAHANA_NSUID=100103 -SAHANA_NSGID=100104 +# Volumes +POSTGRES_DATA="${VOLUMES_DIR}/sahana/postgres_data" +SAHANA_DATA="${VOLUMES_DIR}/sahana/sahana_data" +SAHANA_CONF="${VOLUMES_DIR}/sahana/sahana_conf" # Create Postgres instance -mkdir -p ${VOLUME_DIR}/postgres_data -chown -R ${POSTGRES_NSUID}:${POSTGRES_NSGID} ${VOLUME_DIR}/postgres_data -chmod 700 ${VOLUME_DIR}/postgres_data +install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA} spoc-container exec sahana-postgres -- initdb -D /var/lib/postgresql # Configure Postgres -cp postgres_data/postgresql.conf ${VOLUME_DIR}/postgres_data/postgresql.conf -cp postgres_data/pg_hba.conf ${VOLUME_DIR}/postgres_data/pg_hba.conf +install -o 105432 -g 105432 -m 600 postgres_data/postgresql.conf ${POSTGRES_DATA}/postgresql.conf +install -o 105432 -g 105432 -m 600 postgres_data/pg_hba.conf ${POSTGRES_DATA}/pg_hba.conf # Create PostgreSQL user and database export SAHANA_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') @@ -41,38 +20,34 @@ spoc-container start sahana-postgres envsubst ${VOLUME_DIR}/sahana_conf/000_config.py -envsubst ${VOLUME_DIR}/sahana_data/Spotter/masterUsers.csv -cp sahana_conf/00_settings.py ${VOLUME_DIR}/sahana_conf/00_settings.py -chown -R ${SAHANA_NSUID}:${SAHANA_NSGID} ${VOLUME_DIR}/sahana_conf ${VOLUME_DIR}/sahana_data +envsubst /srv/sambro/sahana_conf/000_config.py -# TODO: -#mkdir -p /var/lib/lxc/sambro/sambro/srv/web2py/applications/eden/modules/templates/default/users -#envsubst /var/lib/lxc/sambro/sambro/srv/web2py/applications/eden/modules/templates/default/users/masterUsers.csv -#chown -R 8080:8080 /var/lib/lxc/sambro/sambro/srv/web2py +envsubst /srv/sambro/sahana_data/masterUsers.csv cp sahana_conf/00_settings.py /srv/sambro/sahana_conf/00_settings.py cp sahana_data/SAMBRO/config.py /srv/sambro/sahana_data/SAMBRO/config.py -# Hackfix for https://github.com/sahana/eden/issues/1530 -echo 'CANARY_UPDATE_CHECK_ID = 4' >/srv/sambro/sahana_conf/0000_update_check.py chown -R 108080:108080 /srv/sambro/sahana_conf /srv/sambro/sahana_data # Populate database