From ae2eea1933e297d17bb2a554af4aa16125879fff Mon Sep 17 00:00:00 2001 From: Disassembler Date: Wed, 13 Dec 2017 17:16:08 +0100 Subject: [PATCH] Add UID/GID for OpenMapKit, change path from omk to openmapkit --- openmapkit.sh | 15 +++++++-------- openmapkit/Dockerfile | 17 ++++++++--------- .../lib/systemd/system/openmapkit.service | 2 +- openmapkit/srv/{omk => openmapkit}/settings.js | 2 +- 4 files changed, 17 insertions(+), 19 deletions(-) rename openmapkit/srv/{omk => openmapkit}/settings.js (97%) diff --git a/openmapkit.sh b/openmapkit.sh index b9f5f73..40d02c4 100755 --- a/openmapkit.sh +++ b/openmapkit.sh @@ -2,16 +2,15 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/openmapkit -# Prepare Docker mount structure -mkdir -p /srv/omk/data/{deployments,submissions} +# Build Docker container +docker build -t openmapkit ${SOURCE_DIR} # Configure OpenMapKit export OMK_ADMIN_USER="admin" export OMK_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) -envsubst <${SOURCE_DIR}/srv/omk/settings.js >/srv/omk/settings.js - -# Build Docker container -docker build -t openmapkit ${SOURCE_DIR} +mkdir -p /srv/openmapkit/data/{deployments,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 @@ -27,5 +26,5 @@ ln -s /etc/nginx/sites-available/openmapkit /etc/nginx/sites-enabled/openmapkit systemctl restart nginx # Add portal application definition -portal-app-manager openmapkit "https://{host}:8007/" admin "${OMK_ADMIN_PWD}" -portal-app-manager openmapkit-clients -p clienturl "http://{host}:8096" +portal-app-manager openmapkit "https://{host}:8407/" admin "${OMK_ADMIN_PWD}" +portal-app-manager openmapkit-clients -p clienturl "http://{host}:8007" diff --git a/openmapkit/Dockerfile b/openmapkit/Dockerfile index 7eefd3d..3f5db73 100644 --- a/openmapkit/Dockerfile +++ b/openmapkit/Dockerfile @@ -4,23 +4,22 @@ MAINTAINER Disassembler RUN apk --no-cache add python2 RUN apk --no-cache add nodejs git build-base openjdk8-jre-base py2-pip \ - && git clone --depth 1 https://github.com/AmericanRedCross/OpenMapKitServer /srv/omk \ - && cd /srv/omk \ + && git clone --depth 1 https://github.com/AmericanRedCross/OpenMapKitServer /srv/openmapkit \ + && cd /srv/openmapkit \ && git submodule update --init \ && pip install -r requirements.txt \ && npm install -g yarn \ && npm install libxmljs \ && yarn \ - && addgroup -S omk \ - && adduser -S -h /srv/omk -H -s /bin/sh -g omk -G omk omk \ - && chown -R omk:omk /srv/omk/data/deployments /srv/omk/data/submissions \ + && addgroup -S -g 8007 omk \ + && adduser -S -u 8007 -h /srv/openmapkit -s /bin/false -g omk -G omk omk \ && apk --no-cache del git build-base py2-pip \ - && rm -rf /srv/omk/.git* /srv/omk/api/odk/pyxform/.git* \ + && rm -rf /srv/openmapkit/.git* /srv/openmapkit/api/odk/pyxform/.git* \ && rm -rf /root/* || true -VOLUME ["/srv/omk/data"] -EXPOSE 3210 +VOLUME ["/srv/openmapkit/data"] +EXPOSE 8007 USER omk ENV NODE_ENV production -CMD ["node", "/srv/omk/server.js"] +CMD ["node", "/srv/openmapkit/server.js"] diff --git a/openmapkit/lib/systemd/system/openmapkit.service b/openmapkit/lib/systemd/system/openmapkit.service index 3699faf..b4b5e7a 100644 --- a/openmapkit/lib/systemd/system/openmapkit.service +++ b/openmapkit/lib/systemd/system/openmapkit.service @@ -4,7 +4,7 @@ After=network.target [Service] Type=simple -ExecStart=/usr/bin/docker run --rm --tmpfs /tmp --name openmapkit -v /srv/omk/settings.js:/srv/omk/settings.js -v /srv/omk/data:/srv/omk/data openmapkit +ExecStart=/usr/bin/docker run --rm --tmpfs /tmp --name openmapkit -v /srv/openmapkit/settings.js:/srv/openmapkit/settings.js -v /srv/openmapkit/data:/srv/openmapkit/data openmapkit ExecStop=/usr/bin/docker kill openmapkit [Install] diff --git a/openmapkit/srv/omk/settings.js b/openmapkit/srv/openmapkit/settings.js similarity index 97% rename from openmapkit/srv/omk/settings.js rename to openmapkit/srv/openmapkit/settings.js index 5f5fcb8..6346040 100644 --- a/openmapkit/srv/omk/settings.js +++ b/openmapkit/srv/openmapkit/settings.js @@ -1,7 +1,7 @@ module.exports = { name: 'OpenMapKit Server', description: 'OpenMapKit Server is the lightweight server component of OpenMapKit that handles the collection and aggregation of OpenStreetMap and OpenDataKit data.', - port: 8096, + port: 8007, dataDir: __dirname + '/data', pagesDir: __dirname + '/pages', hostUrl: 'http://posm.io',