diff --git a/openmapkit.sh b/openmapkit.sh index 40d02c4..5015784 100755 --- a/openmapkit.sh +++ b/openmapkit.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh SOURCE_DIR=$(realpath $(dirname "${0}"))/openmapkit @@ -8,22 +8,22 @@ docker build -t openmapkit ${SOURCE_DIR} # Configure OpenMapKit export OMK_ADMIN_USER="admin" export OMK_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) -mkdir -p /srv/openmapkit/data/{deployments,submissions} +mkdir -p /srv/openmapkit/data/deployments +mkdir /srv/openmapkit/data/submissions envsubst <${SOURCE_DIR}/srv/openmapkit/settings.js >/srv/openmapkit/settings.js chown -R 8007:8007 /srv/openmapkit/data # Configure OpenMapKit service -cp ${SOURCE_DIR}/lib/systemd/system/openmapkit.service /lib/systemd/system/openmapkit.service -systemctl daemon-reload -systemctl enable openmapkit -systemctl start openmapkit +cp ${SOURCE_DIR}/etc/init.d/openmapkit /etc/init.d/openmapkit +rc-update add openmapkit boot +service openmapkit start # Create nginx site definition -cp ${SOURCE_DIR}/etc/nginx/sites-available/openmapkit /etc/nginx/sites-available/openmapkit -ln -s /etc/nginx/sites-available/openmapkit /etc/nginx/sites-enabled/openmapkit +cp ${SOURCE_DIR}/etc/nginx/apps/openmapkit /etc/nginx/apps/openmapkit +cp ${SOURCE_DIR}/etc/nginx/conf.d/openmapkit.conf /etc/nginx/conf.d/openmapkit.conf -# Restart services -systemctl restart nginx +# Reload nginx configuration +service nginx reload # Add portal application definition portal-app-manager openmapkit "https://{host}:8407/" admin "${OMK_ADMIN_PWD}" diff --git a/openmapkit/Dockerfile b/openmapkit/Dockerfile index 4a560fd..4cfc9b3 100644 --- a/openmapkit/Dockerfile +++ b/openmapkit/Dockerfile @@ -3,8 +3,9 @@ MAINTAINER Disassembler RUN apk --no-cache add python2 -RUN apk --no-cache add --virtual .deps git build-base py2-pip \ - && apk add nodejs git openjdk8-jre-base \ +RUN apk --no-cache add --virtual .deps git build-base paxctl py2-pip \ + && apk --no-cache add nodejs git openjdk8-jre-base \ + && paxctl -cm /usr/bin/node \ && git clone --depth 1 https://github.com/AmericanRedCross/OpenMapKitServer /srv/openmapkit \ && cd /srv/openmapkit \ && git submodule update --init \ diff --git a/openmapkit/etc/init.d/openmapkit b/openmapkit/etc/init.d/openmapkit new file mode 100755 index 0000000..69783c7 --- /dev/null +++ b/openmapkit/etc/init.d/openmapkit @@ -0,0 +1,16 @@ +#!/sbin/openrc-run + +description="OpenMapKit docker container" + +depend() { + need docker net + use dns logger netmount +} + +start() { + /usr/bin/docker run -d --rm --name openmapkit -p 127.0.0.1:9007:8007 -v /srv/openmapkit/settings.js:/srv/openmapkit/settings.js -v /srv/openmapkit/data:/srv/openmapkit/data openmapkit +} + +stop() { + /usr/bin/docker kill openmapkit +} diff --git a/openmapkit/etc/nginx/apps/openmapkit b/openmapkit/etc/nginx/apps/openmapkit new file mode 100644 index 0000000..289aab2 --- /dev/null +++ b/openmapkit/etc/nginx/apps/openmapkit @@ -0,0 +1,9 @@ +access_log /var/log/nginx/openmapkit.access.log; +error_log /var/log/nginx/openmapkit.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 https; + proxy_pass http://127.0.0.1:9007; +} diff --git a/openmapkit/etc/nginx/conf.d/openmapkit.conf b/openmapkit/etc/nginx/conf.d/openmapkit.conf new file mode 100644 index 0000000..968ef8e --- /dev/null +++ b/openmapkit/etc/nginx/conf.d/openmapkit.conf @@ -0,0 +1,11 @@ +server { + listen 8007; + listen [::]:8007; + include apps/openmapkit; +} + +server { + listen 8407 ssl http2; + listen [::]:8407 ssl http2; + include apps/openmapkit; +} diff --git a/openmapkit/etc/nginx/sites-available/openmapkit b/openmapkit/etc/nginx/sites-available/openmapkit deleted file mode 100644 index 35e293a..0000000 --- a/openmapkit/etc/nginx/sites-available/openmapkit +++ /dev/null @@ -1,14 +0,0 @@ -server { - listen 8007 ssl http2; - listen [::]:8007 ssl http2; - - access_log /var/log/nginx/openmapkit.access.log; - error_log /var/log/nginx/openmapkit.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 https; - proxy_pass http://127.0.0.1:8096; - } -} diff --git a/openmapkit/lib/systemd/system/openmapkit.service b/openmapkit/lib/systemd/system/openmapkit.service deleted file mode 100644 index 9c10491..0000000 --- a/openmapkit/lib/systemd/system/openmapkit.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=OpenMapKit Docker container -After=network.target - -[Service] -Type=simple -ExecStart=/usr/bin/docker run --rm --name openmapkit -p 127.0.0.1:9007:8007 -v /srv/openmapkit/settings.js:/srv/openmapkit/settings.js -v /srv/openmapkit/data:/srv/openmapkit/data openmapkit -ExecStop=/usr/bin/docker kill openmapkit - -[Install] -WantedBy=multi-user.target