Alpinize + Dockerize GNU Health
This commit is contained in:
parent
96e3bd4a5f
commit
6709ee478a
@ -68,3 +68,4 @@ vi 00-install.sh
|
|||||||
| Crisis Cleanup | 8005 | 8405 |
|
| Crisis Cleanup | 8005 | 8405 |
|
||||||
| CTS | 8006 | 8406 |
|
| CTS | 8006 | 8406 |
|
||||||
| OpenMapKit | 8007 | 8407 |
|
| OpenMapKit | 8007 | 8407 |
|
||||||
|
| GNU Health | 8008 | 8408 |
|
||||||
|
79
gnuhealth.sh
79
gnuhealth.sh
@ -2,79 +2,38 @@
|
|||||||
|
|
||||||
SOURCE_DIR=$(realpath $(dirname "${0}"))/gnuhealth
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/gnuhealth
|
||||||
|
|
||||||
# Install dependencies for GNU Health
|
# Build Docker container
|
||||||
apt-get -y --no-install-recommends install python3 python3-virtualenv virtualenv
|
docker build -t gnuhealth ${SOURCE_DIR}
|
||||||
|
|
||||||
# Add NodeJS repository for Sao (Tryton web client)
|
|
||||||
wget https://deb.nodesource.com/gpgkey/nodesource.gpg.key -O - | apt-key add -
|
|
||||||
echo 'deb https://deb.nodesource.com/node_8.x stretch main' > /etc/apt/sources.list.d/nodejs.list
|
|
||||||
apt-get -y update
|
|
||||||
|
|
||||||
# Install dependencies for Sao (Tryton web client)
|
|
||||||
apt-get -y --no-install-recommends install nodejs
|
|
||||||
|
|
||||||
# Download GNU Health
|
|
||||||
wget http://ftp.gnu.org/gnu/health/gnuhealth-3.2.8.tar.gz -O /tmp/gnuhealth.tgz
|
|
||||||
tar xzf /tmp/gnuhealth.tgz -C /srv
|
|
||||||
mv /srv/gnuhealth-3.2.8 /srv/gnuhealth
|
|
||||||
rm -f /tmp/gnuhealth.tgz
|
|
||||||
|
|
||||||
# Clone Sao (Tryton web client) repository
|
|
||||||
git clone -b 4.2 --single-branch --depth 1 https://github.com/tryton/sao /srv/gnuhealth/sao
|
|
||||||
|
|
||||||
# Apply Sao (Tryton web client) dependencies patch
|
|
||||||
patch -d /srv/gnuhealth/sao -p0 <${SOURCE_DIR}/gnuhealth-sao-dependencies.patch
|
|
||||||
|
|
||||||
# Create Python virtualenv
|
|
||||||
virtualenv --system-site-packages -p /usr/bin/python3 /srv/gnuhealth
|
|
||||||
echo '. /srv/gnuhealth/bin/activate' >/srv/gnuhealth/.bash_profile
|
|
||||||
|
|
||||||
# Create databases
|
# Create databases
|
||||||
export GNUHEALTH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '/+=')
|
export GNUHEALTH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '/+=')
|
||||||
envsubst <${SOURCE_DIR}/tmp/gnuhealth-createdb.sql >/tmp/gnuhealth-createdb.sql
|
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql
|
||||||
sudo -u postgres psql -f /tmp/gnuhealth-createdb.sql
|
|
||||||
rm -f /tmp/gnuhealth-createdb.sql
|
|
||||||
|
|
||||||
# Create GNU Health OS user
|
|
||||||
adduser --system --group --home /srv/gnuhealth --shell /bin/bash gnuhealth
|
|
||||||
chown -R gnuhealth:gnuhealth /srv/gnuhealth
|
|
||||||
|
|
||||||
# Install GNU Health
|
|
||||||
sudo -u gnuhealth -i /srv/gnuhealth/gnuhealth-setup install
|
|
||||||
|
|
||||||
# Install Sao (Tryton web client)
|
|
||||||
sudo -u gnuhealth npm install --production --prefix /srv/gnuhealth/sao
|
|
||||||
sudo -u gnuhealth bash -c 'cd /srv/gnuhealth/sao && /srv/gnuhealth/sao/node_modules/grunt-cli/bin/grunt'
|
|
||||||
|
|
||||||
# Configure GNU Health
|
# Configure GNU Health
|
||||||
envsubst <${SOURCE_DIR}/srv/gnuhealth/gnuhealth/tryton/server/config/trytond.conf >/srv/gnuhealth/gnuhealth/tryton/server/config/trytond.conf
|
mkdir -p /srv/gnuhealth/conf/
|
||||||
|
envsubst <${SOURCE_DIR}/srv/gnuhealth/conf/trytond.conf >/srv/gnuhealth/conf/trytond.conf
|
||||||
|
|
||||||
# Populate database
|
# Populate database
|
||||||
export GNUHEALTH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
|
export GNUHEALTH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
|
||||||
echo ${GNUHEALTH_ADMIN_PWD} >/srv/gnuhealth/.adminpwd
|
echo ${GNUHEALTH_ADMIN_PWD} >/tmp/.adminpwd
|
||||||
sudo -u gnuhealth -i TRYTONPASSFILE=/srv/gnuhealth/.adminpwd /srv/gnuhealth/gnuhealth/tryton/server/trytond-4.2.8/bin/trytond-admin -d gnuhealth --all -v
|
docker run --rm --link=postgres -v /srv/gnuhealth/conf:/srv/gnuhealth/gnuhealth/tryton/server/config -v /tmp/.adminpwd:/tmp/.adminpwd -e TRYTONPASSFILE=/tmp/.adminpwd gnuhealth /srv/gnuhealth/gnuhealth/tryton/server/trytond-4.2.8/bin/trytond-admin -d gnuhealth --all -v
|
||||||
rm -f /srv/gnuhealth/.adminpwd
|
rm -f /tmp/.adminpwd
|
||||||
|
|
||||||
# Populate demo database
|
# Populate demo database
|
||||||
wget http://health.gnu.org/downloads/postgres_dumps/gnuhealth-3.2rc1.sql.gz -O /tmp/gnuhealth_demo.sql.gz
|
wget http://health.gnu.org/downloads/postgres_dumps/gnuhealth-3.2rc1.sql.gz -O /tmp/gnuhealth_demo.sql.gz
|
||||||
export PGPASSWORD=${GNUHEALTH_PWD}
|
zcat /tmp/gnuhealth_demo.sql.gz | docker exec -i -e PGPASSWORD=${GNUHEALTH_PWD} postgres psql gnuhealth_demo gnuhealth
|
||||||
zcat /tmp/gnuhealth_demo.sql.gz | psql gnuhealth_demo gnuhealth
|
|
||||||
unset PGPASSWORD
|
|
||||||
rm -f /tmp/gnuhealth_demo.sql.gz
|
rm -f /tmp/gnuhealth_demo.sql.gz
|
||||||
|
|
||||||
# Configure GNU Health service
|
# Create GNU Health service
|
||||||
cp ${SOURCE_DIR}/lib/systemd/system/gnuhealth.service /lib/systemd/system/gnuhealth.service
|
cp ${SOURCE_DIR}/etc/init.d/gnuhealth /etc/init.d/gnuhealth
|
||||||
systemctl daemon-reload
|
rc-update add gnuhealth boot
|
||||||
systemctl enable gnuhealth
|
service gnuhealth start
|
||||||
systemctl start gnuhealth
|
|
||||||
|
|
||||||
# Create nginx site definition
|
# Create nginx app definition
|
||||||
cp ${SOURCE_DIR}/etc/nginx/sites-available/gnuhealth /etc/nginx/sites-available/gnuhealth
|
cp ${SOURCE_DIR}/etc/nginx/apps/gnuhealth /etc/nginx/apps/gnuhealth
|
||||||
ln -s /etc/nginx/sites-available/gnuhealth /etc/nginx/sites-enabled/gnuhealth
|
cp ${SOURCE_DIR}/etc/nginx/conf.d/gnuhealth.conf /etc/nginx/conf.d/gnuhealth.conf
|
||||||
|
service nginx reload
|
||||||
# Restart nginx
|
|
||||||
systemctl restart nginx
|
|
||||||
|
|
||||||
# Add portal application definition
|
# Add portal application definition
|
||||||
portal-app-manager gnuhealth "https://{host}:8006/index.html" admin "${GNUHEALTH_ADMIN_PWD}"
|
portal-app-manager gnuhealth "https://{host}:8408/index.html" admin "${GNUHEALTH_ADMIN_PWD}"
|
||||||
portal-app-manager gnuhealth-clients -p clienturl "{host}:8006"
|
portal-app-manager gnuhealth-clients -p clienturl "{host}:8008"
|
||||||
|
52
gnuhealth/Dockerfile
Normal file
52
gnuhealth/Dockerfile
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
FROM alpine:3.7
|
||||||
|
MAINTAINER Disassembler <disassembler@dasm.cz>
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
# Install Python3 runtime
|
||||||
|
apk --no-cache add python3
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
# Install runtime XML dependencies
|
||||||
|
apk --no-cache add libxml2 libxslt
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
# Install runtime dependencies
|
||||||
|
apk --no-cache add bash coreutils libffi libjpeg-turbo libpq nodejs \
|
||||||
|
# Install build dependencies
|
||||||
|
&& apk --no-cache add --virtual .deps build-base git libffi-dev libjpeg-turbo-dev libxml2-dev libxslt-dev ncurses patch postgresql-dev python3-dev sudo \
|
||||||
|
# Download GNU Health
|
||||||
|
&& wget http://ftp.gnu.org/gnu/health/gnuhealth-3.2.8.tar.gz -O /tmp/gnuhealth.tgz \
|
||||||
|
&& tar xzf /tmp/gnuhealth.tgz -C /srv \
|
||||||
|
&& mv /srv/gnuhealth-3.2.8 /srv/gnuhealth \
|
||||||
|
&& rm -f /tmp/gnuhealth.tgz \
|
||||||
|
# Clone Sao (Tryton web client) repository
|
||||||
|
&& git clone -b 4.2 --single-branch --depth 1 https://github.com/tryton/sao /srv/gnuhealth/sao \
|
||||||
|
# Symlink python binary
|
||||||
|
&& ln -s /usr/bin/python3 /usr/bin/python \
|
||||||
|
# Create OS user
|
||||||
|
&& addgroup -S -g 8008 gnuhealth \
|
||||||
|
&& adduser -S -u 8008 -h /srv/gnuhealth -s /bin/bash -g gnuhealth -G gnuhealth gnuhealth \
|
||||||
|
&& chown -R gnuhealth:gnuhealth /srv/gnuhealth \
|
||||||
|
# Install GNU Health
|
||||||
|
&& cd /srv/gnuhealth \
|
||||||
|
&& sudo -u gnuhealth ./gnuhealth-setup install \
|
||||||
|
# Install Sao (Tryton web client) dependencies
|
||||||
|
&& cd /srv/gnuhealth/sao \
|
||||||
|
&& sudo -u gnuhealth npm install grunt grunt-cli grunt-contrib-concat grunt-contrib-jshint grunt-contrib-uglify grunt-contrib-less grunt-po2json \
|
||||||
|
&& sudo -u gnuhealth npm install --production \
|
||||||
|
&& sudo -u gnuhealth ./node_modules/.bin/grunt \
|
||||||
|
# Cleanup
|
||||||
|
&& apk del .deps \
|
||||||
|
&& find /srv/gnuhealth -name '.git*' -exec rm -rf {} + \
|
||||||
|
&& rm -rf /usr/local/share/.cache \
|
||||||
|
&& rm -rf /root \
|
||||||
|
&& mkdir /root
|
||||||
|
|
||||||
|
VOLUME ["/srv/gnuhealth/gnuhealth/tryton/server/config"]
|
||||||
|
EXPOSE 8008
|
||||||
|
|
||||||
|
USER gnuhealth
|
||||||
|
ENV PATH=/srv/gnuhealth/gnuhealth/tryton/server/trytond-4.2.8/bin:${PATH} \
|
||||||
|
TRYTOND_CONFIG=/srv/gnuhealth/gnuhealth/tryton/server/config/trytond.conf \
|
||||||
|
PYTHONPATH=/srv/gnuhealth/gnuhealth/tryton/server/trytond-4.2.8:/srv/gnuhealth/gnuhealth/tryton/server/config
|
||||||
|
CMD ["trytond", "--verbose"]
|
17
gnuhealth/etc/init.d/gnuhealth
Executable file
17
gnuhealth/etc/init.d/gnuhealth
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/sbin/openrc-run
|
||||||
|
|
||||||
|
description="GNU Health docker container"
|
||||||
|
|
||||||
|
depend() {
|
||||||
|
need docker net
|
||||||
|
use dns logger netmount
|
||||||
|
after postgres
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
/usr/bin/docker run -d --rm --name gnuhealth --link=postgres -p 127.0.0.1:9008:8008 -v /srv/gnuhealth/conf:/srv/gnuhealth/gnuhealth/tryton/server/config gnuhealth
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
/usr/bin/docker stop gnuhealth
|
||||||
|
}
|
9
gnuhealth/etc/nginx/apps/gnuhealth
Normal file
9
gnuhealth/etc/nginx/apps/gnuhealth
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
access_log /var/log/nginx/gnuhealth.access.log;
|
||||||
|
error_log /var/log/nginx/gnuhealth.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:9008;
|
||||||
|
}
|
11
gnuhealth/etc/nginx/conf.d/gnuhealth.conf
Normal file
11
gnuhealth/etc/nginx/conf.d/gnuhealth.conf
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
server {
|
||||||
|
listen 8008;
|
||||||
|
listen [::]:8008;
|
||||||
|
include apps/gnuhealth;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 8408 ssl http2;
|
||||||
|
listen [::]:8408 ssl http2;
|
||||||
|
include apps/gnuhealth;
|
||||||
|
}
|
@ -1,17 +0,0 @@
|
|||||||
server {
|
|
||||||
listen 8006 ssl http2;
|
|
||||||
listen [::]:8006 ssl http2;
|
|
||||||
|
|
||||||
access_log /var/log/nginx/gnuhealth.access.log;
|
|
||||||
error_log /var/log/nginx/gnuhealth.error.log;
|
|
||||||
|
|
||||||
root /srv/gnuhealth/sao;
|
|
||||||
try_files $uri @gnuhealth;
|
|
||||||
|
|
||||||
location @gnuhealth {
|
|
||||||
proxy_set_header X-Forwarded-For $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-Host $host:$server_port;
|
|
||||||
proxy_set_header X-Forwarded-Proto https;
|
|
||||||
proxy_pass http://127.0.0.1:8097;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
--- package.bak 2017-12-03 23:27:54.280162096 +0100
|
|
||||||
+++ package.json 2017-12-03 23:29:24.384721720 +0100
|
|
||||||
@@ -54,6 +54,13 @@
|
|
||||||
"tryton"
|
|
||||||
],
|
|
||||||
"dependencies": {
|
|
||||||
+ "grunt": "^0.4",
|
|
||||||
+ "grunt-cli": "^0.1",
|
|
||||||
+ "grunt-contrib-concat": "^0.5",
|
|
||||||
+ "grunt-contrib-jshint": "^0.11",
|
|
||||||
+ "grunt-contrib-uglify": "^0.9",
|
|
||||||
+ "grunt-contrib-less": "^1.2",
|
|
||||||
+ "grunt-po2json": "^0.3",
|
|
||||||
"bower": "^1.7"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=GNU Health Server
|
|
||||||
After=network.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
User=gnuhealth
|
|
||||||
Environment=TRYTOND_CONFIG=/srv/gnuhealth/gnuhealth/tryton/server/config/trytond.conf
|
|
||||||
Environment=VIRTUAL_ENV=/srv/gnuhealth
|
|
||||||
Environment=PYTHONPATH=/srv/gnuhealth/gnuhealth/tryton/server/trytond-4.2.8:/srv/gnuhealth/gnuhealth/tryton/server/config
|
|
||||||
Environment=PATH=/srv/gnuhealth/bin:/usr/local/bin:/usr/bin:/bin
|
|
||||||
WorkingDirectory=/srv/gnuhealth
|
|
||||||
ExecStart=/srv/gnuhealth/gnuhealth/tryton/server/trytond-4.2.8/bin/trytond
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
@ -1,9 +1,9 @@
|
|||||||
[database]
|
[database]
|
||||||
uri = postgresql://gnuhealth:${GNUHEALTH_PWD}@localhost
|
uri = postgresql://gnuhealth:${GNUHEALTH_PWD}@postgres
|
||||||
path = /srv/gnuhealth/attach
|
path = /srv/gnuhealth/attach
|
||||||
|
|
||||||
[web]
|
[web]
|
||||||
listen = 127.0.0.1:8097
|
listen = 0.0.0.0:8008
|
||||||
root = /srv/gnuhealth/sao
|
root = /srv/gnuhealth/sao
|
||||||
|
|
||||||
[webdav]
|
[webdav]
|
Loading…
Reference in New Issue
Block a user