Make GNU Health SPOC-compatible

This commit is contained in:
Disassembler 2020-03-17 13:39:43 +01:00
parent 797e900268
commit 8f27ee6afe
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
5 changed files with 54 additions and 63 deletions

26
lxc-apps/gnuhealth/app Normal file
View File

@ -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"
}
}
}
}

View File

@ -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

View File

@ -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 <createdb.sql | lxc-attach -u 5432 -g 5432 gnuhealth-postgres -- psql
spoc-container start gnuhealth-postgres
envsubst <createdb.sql | spoc-container exec gnuhealth-postgres -- psql
# Configure GNU Health
mkdir -p /srv/gnuhealth/gnuhealth_conf/
envsubst <gnuhealth_conf/trytond.conf >/srv/gnuhealth/gnuhealth_conf/trytond.conf
install -o 108080 -g 108080 -m 750 -d ${GNUHEALTH_CONF}
envsubst <gnuhealth_conf/trytond.conf | install -o 108080 -g 108080 -m 640 /dev/stdin ${GNUHEALTH_CONF}/trytond.conf
# Populate database
export GNUHEALTH_ADMIN_USER="admin"
export GNUHEALTH_ADMIN_EMAIL="admin@example.com"
export GNUHEALTH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
lxc-execute gnuhealth -- sh -c "echo ${GNUHEALTH_ADMIN_PWD} >/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}"

View File

@ -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"]
]
}
}
}

View File

@ -2,7 +2,7 @@
set -ev
# Remove persistent data
rm -rf /srv/gnuhealth
rm -rf "${VOLUMES_DIR}/gnuhealth"
# Unregister application
vmmgr unregister-app gnuhealth