From 8f27ee6afe4a41d15c7432a1e4da0adfc0d8b9fd Mon Sep 17 00:00:00 2001 From: Disassembler Date: Tue, 17 Mar 2020 13:39:43 +0100 Subject: [PATCH] Make GNU Health SPOC-compatible --- lxc-apps/gnuhealth/app | 26 ++++++++++++++++++++++ lxc-apps/gnuhealth/{lxcfile => image} | 31 +++++++++----------------- lxc-apps/gnuhealth/install.sh | 32 +++++++++++++-------------- lxc-apps/gnuhealth/meta | 26 ---------------------- lxc-apps/gnuhealth/uninstall.sh | 2 +- 5 files changed, 54 insertions(+), 63 deletions(-) create mode 100644 lxc-apps/gnuhealth/app rename lxc-apps/gnuhealth/{lxcfile => image} (63%) delete mode 100644 lxc-apps/gnuhealth/meta diff --git a/lxc-apps/gnuhealth/app b/lxc-apps/gnuhealth/app new file mode 100644 index 0000000..9867f38 --- /dev/null +++ b/lxc-apps/gnuhealth/app @@ -0,0 +1,26 @@ +{ + "version": "3.6.3-200313", + "meta": { + "title": "GNU Health", + "desc-cs": "Lékařské záznamy pacientů", + "desc-en": "Medical records administration", + "license": "GPL" + }, + "containers": { + "gnuhealth": { + "image": "gnuhealth_3.6.3-200313", + "depends": [ + "gnuhealth-postgres" + ], + "mounts": { + "gnuhealth/gnuhealth_conf": "srv/gnuhealth/gnuhealth/tryton/server/config" + } + }, + "gnuhealth-postgres": { + "image": "postgres_12.2.0-200313", + "mounts": { + "gnuhealth/postgres_data": "var/lib/postgresql" + } + } + } +} diff --git a/lxc-apps/gnuhealth/lxcfile b/lxc-apps/gnuhealth/image similarity index 63% rename from lxc-apps/gnuhealth/lxcfile rename to lxc-apps/gnuhealth/image index b849fc1..68ee947 100644 --- a/lxc-apps/gnuhealth/lxcfile +++ b/lxc-apps/gnuhealth/image @@ -1,5 +1,5 @@ -IMAGE gnuhealth_3.4.1-190620 -FROM alpine3.9-python3.6_3.6.8-190620 +IMAGE gnuhealth_3.6.3-200313 +FROM alpine3.11-python3.8_3.8.2-200313 RUN EOF # Install runtime dependencies @@ -9,15 +9,8 @@ RUN EOF apk --no-cache add --virtual .deps build-base git libffi-dev libjpeg-turbo-dev libxml2-dev libxslt-dev ncurses npm patch postgresql-dev python3-dev sudo # Download GNU Health - wget http://ftp.gnu.org/gnu/health/gnuhealth-3.4.1.tar.gz -O /tmp/gnuhealth.tgz - tar xzf /tmp/gnuhealth.tgz -C /srv - mv /srv/gnuhealth-3.4.1 /srv/install - - # Hackfix python-barcode support (will work in 3.4.2 - see http://hg.savannah.gnu.org/hgweb/health/rev/61b7bc7b1a78) - sed -i 's/pybarcode/python-barcode/' /srv/install/gnuhealth-setup - - # Clone Sao (Tryton web client) repository - git clone -b 4.6 --single-branch --depth 1 https://github.com/tryton/sao /srv/gnuhealth/sao + wget http://ftp.gnu.org/gnu/health/gnuhealth-3.6.3.tar.gz -O - | tar xzf - -C /srv + mv /srv/gnuhealth-* /srv/install # Create OS user addgroup -S -g 8080 gnuhealth @@ -31,11 +24,10 @@ RUN EOF # Create symlink for the current version of trytond ln -s /srv/gnuhealth/gnuhealth/tryton/server/trytond-* /srv/gnuhealth/gnuhealth/tryton/server/trytond-current - # Hackfix extraneous pymongo requirement - sed -i '/pymongo/d' /srv/gnuhealth/gnuhealth/tryton/server/modules/health_federation/health_federation.py - - # Hackfix template1 database lock - sed -i 's/template1/gnuhealth/g' /srv/gnuhealth/gnuhealth/tryton/server/trytond-current/trytond/backend/postgresql/database.py + # Clone Sao (Tryton web client) repository + # Note: Sao version needs to be the same as Tryton version installed by GNU Health + git clone -b 5.0 --single-branch --depth 1 https://github.com/tryton/sao /srv/gnuhealth/sao + chown -R gnuhealth:gnuhealth /srv/gnuhealth/sao # Install Sao (Tryton web client) dependencies cd /srv/gnuhealth/sao @@ -43,18 +35,17 @@ RUN EOF sudo -u gnuhealth ./node_modules/grunt-cli/bin/grunt # Download Demo database - wget http://health.gnu.org/downloads/postgres_dumps/gnuhealth-34-demo.sql.gz -O /srv/gnuhealth/gnuhealth_demo.sql.gz + wget http://health.gnu.org/downloads/postgres_dumps/gnuhealth-36-demo.sql.gz -O /srv/gnuhealth/gnuhealth_demo.sql.gz # Cleanup apk --no-cache del .deps find /srv/gnuhealth -name '.git*' -exec rm -rf {} + rm -rf /srv/install - rm -f /tmp/gnuhealth.tgz EOF ENV PATH /srv/gnuhealth/gnuhealth/tryton/server/trytond-current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin ENV TRYTOND_CONFIG /srv/gnuhealth/gnuhealth/tryton/server/config/trytond.conf ENV PYTHONPATH /srv/gnuhealth/gnuhealth/tryton/server/trytond-current:/srv/gnuhealth/gnuhealth/tryton/server/config -USER 8080 8080 -CMD trytond --verbose +USER gnuhealth +CMD /srv/gnuhealth/gnuhealth/tryton/server/trytond-current/bin/trytond --verbose diff --git a/lxc-apps/gnuhealth/install.sh b/lxc-apps/gnuhealth/install.sh index 6d10a17..40f2e33 100755 --- a/lxc-apps/gnuhealth/install.sh +++ b/lxc-apps/gnuhealth/install.sh @@ -1,38 +1,38 @@ #!/bin/sh set -ev +# Volumes +POSTGRES_DATA="${VOLUMES_DIR}/gnuhealth/postgres_data" +GNUHEALTH_CONF="${VOLUMES_DIR}/gnuhealth/gnuhealth_conf" + # Create Postgres instance -mkdir -p /srv/gnuhealth/postgres_data -chown -R 105432:105432 /srv/gnuhealth/postgres_data -chmod 700 /srv/gnuhealth/postgres_data -lxc-execute -n gnuhealth-postgres -- initdb -D /var/lib/postgresql +install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA} +spoc-container exec gnuhealth-postgres -- initdb -D /var/lib/postgresql # Configure Postgres -cp postgres_data/postgresql.conf /srv/gnuhealth/postgres_data/postgresql.conf -cp postgres_data/pg_hba.conf /srv/gnuhealth/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 databases export GNUHEALTH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') -service lxc-gnuhealth-postgres start -envsubst /srv/gnuhealth/gnuhealth_conf/trytond.conf +install -o 108080 -g 108080 -m 750 -d ${GNUHEALTH_CONF} +envsubst /tmp/.adminpwd; TRYTONPASSFILE=/tmp/.adminpwd trytond-admin -d gnuhealth --all -v; rm /tmp/.adminpwd" +spoc-container exec gnuhealth -- sh -c "echo ${GNUHEALTH_ADMIN_PWD} >/tmp/.adminpwd; TRYTONPASSFILE=/tmp/.adminpwd trytond-admin -d gnuhealth --email ${GNUHEALTH_ADMIN_EMAIL} --all -v; rm /tmp/.adminpwd" # Populate demo database -lxc-execute gnuhealth -- zcat /srv/gnuhealth/gnuhealth_demo.sql.gz | lxc-attach -u 5432 -g 5432 gnuhealth-postgres -- sh -c "PGPASSWORD=${GNUHEALTH_PWD} psql gnuhealth_demo gnuhealth" - -# Install config update script -cp update-conf.sh /srv/gnuhealth/update-conf.sh +spoc-container exec gnuhealth -- zcat /srv/gnuhealth/gnuhealth_demo.sql.gz | spoc-container exec gnuhealth-postgres -- sh -c "PGPASSWORD=${GNUHEALTH_PWD} psql gnuhealth_demo gnuhealth" # Stop services required for setup -service lxc-gnuhealth-postgres stop +spoc-container stop gnuhealth-postgres # Register application vmmgr register-app gnuhealth gh "${GNUHEALTH_ADMIN_USER}" "${GNUHEALTH_ADMIN_PWD}" diff --git a/lxc-apps/gnuhealth/meta b/lxc-apps/gnuhealth/meta deleted file mode 100644 index 1b402cd..0000000 --- a/lxc-apps/gnuhealth/meta +++ /dev/null @@ -1,26 +0,0 @@ -{ - "version": "3.4.1-190620", - "meta": { - "title": "GNU Health", - "desc-cs": "Lékařské záznamy pacientů", - "desc-en": "Medical records administration", - "license": "GPL" - }, - "containers": { - "gnuhealth": { - "image": "gnuhealth_3.4.1-190620", - "depends": [ - "gnuhealth-postgres" - ], - "mounts": [ - ["DIR", "/srv/gnuhealth/gnuhealth_conf", "/srv/gnuhealth/gnuhealth/tryton/server/config"] - ] - }, - "gnuhealth-postgres": { - "image": "postgres_11.3.0-190620", - "mounts": [ - ["DIR", "/srv/gnuhealth/postgres_data", "/var/lib/postgresql"] - ] - } - } -} diff --git a/lxc-apps/gnuhealth/uninstall.sh b/lxc-apps/gnuhealth/uninstall.sh index 5a98aa4..196c7e8 100755 --- a/lxc-apps/gnuhealth/uninstall.sh +++ b/lxc-apps/gnuhealth/uninstall.sh @@ -2,7 +2,7 @@ set -ev # Remove persistent data -rm -rf /srv/gnuhealth +rm -rf "${VOLUMES_DIR}/gnuhealth" # Unregister application vmmgr unregister-app gnuhealth