diff --git a/basic/srv/portal/index.html b/basic/srv/portal/index.html index 92aa858..a2bd9aa 100644 --- a/basic/srv/portal/index.html +++ b/basic/srv/portal/index.html @@ -96,6 +96,11 @@ +
+

Open Data KitOpen Data Kit Build

+

Sběr dat s pomocí smartphone.
Aplikace pro návrh formulářů

+
+

Open Map KitOpen Data Kit

Sběr dat s pomocí smartphone.
diff --git a/opendatakit-build.sh b/opendatakit-build.sh new file mode 100755 index 0000000..96e278b --- /dev/null +++ b/opendatakit-build.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SOURCE_DIR=$(realpath $(dirname "${0}"))/opendatakit-build + +# Check prerequisites +docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh +docker image ls | grep -q ruby || $(realpath $(dirname "${0}"))/ruby.sh + +# Build Docker container +docker build -t opendatakit-build ${SOURCE_DIR} + +# Create databases +export ODKBUILD_PWD=$(head -c 18 /dev/urandom | base64) +envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql + +# Configure OpenDataKit Build +export ODKBUILD_COOKIE_SECRET=$(head -c 8 /dev/urandom | hexdump -e '"%x"') +mkdir -p /srv/opendatakit-build/conf +envsubst <${SOURCE_DIR}/srv/opendatakit-build/conf/config.yml >/srv/opendatakit-build/conf/config.yml +docker run --rm -h opendatakit-build --link postgres -v /srv/opendatakit-build/conf/config.yml:/srv/odkbuild/config.yml opendatakit-build rake db:migrate + +# Create OpenDataKit service +cp ${SOURCE_DIR}/etc/init.d/opendatakit-build /etc/init.d/opendatakit-build +rc-update add opendatakit-build +service opendatakit-build start + +# Create nginx app definition +cp ${SOURCE_DIR}/etc/nginx/conf.d/opendatakit-build.conf /etc/nginx/conf.d/opendatakit-build.conf +service nginx reload + +# Add portal application definition +portal-app-manager opendatakit-build "https://{host}:8416/" diff --git a/opendatakit-build/Dockerfile b/opendatakit-build/Dockerfile new file mode 100644 index 0000000..9408f64 --- /dev/null +++ b/opendatakit-build/Dockerfile @@ -0,0 +1,34 @@ +FROM ruby +MAINTAINER Disassembler + +RUN \ + # Install runtime dependencies + apk --no-cache add libpq + +RUN \ + # Install build dependencies + apk --no-cache add --virtual .deps build-base git linux-headers openjdk8-jre-base paxctl postgresql-dev \ + # Fix grsec attributes to loosen memory protection restrictions + && paxctl -cm /usr/lib/jvm/java-1.8-openjdk/jre/bin/java \ + && paxctl -cm /usr/lib/jvm/java-1.8-openjdk/bin/java \ + # Clone ODK Build + && git clone --depth 1 https://github.com/opendatakit/build /srv/odkbuild \ + # Install Ruby dependencies + && cd /srv/odkbuild \ + && bundle install --without test \ + && rake deploy:build \ + # Create OS user + && addgroup -S -g 8016 odkbuild \ + && adduser -S -u 8016 -h /srv/odkbuild -s /bin/false -g odkbuild -G odkbuild odkbuild \ + && chown -R odkbuild:odkbuild /srv/odkbuild \ + # Cleanup + && apk --no-cache del .deps \ + && find /srv/odkbuild -name '.git*' -exec rm -rf {} + \ + && rm -rf /root/.bundle + +# VOLUME ["/srv/crisiscleanup/config"] +EXPOSE 8016 + +USER odkbuild +WORKDIR /srv/odkbuild +CMD ["bundle", "exec", "rackup", "config.ru", "-o", "0.0.0.0", "-p", "8016"] diff --git a/opendatakit-build/createdb.sql b/opendatakit-build/createdb.sql new file mode 100644 index 0000000..315bad6 --- /dev/null +++ b/opendatakit-build/createdb.sql @@ -0,0 +1,4 @@ +CREATE ROLE odkbuild NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN ENCRYPTED PASSWORD '${ODKBUILD_PWD}'; +CREATE DATABASE odkbuild; +REVOKE ALL ON DATABASE odkbuild FROM public; +ALTER DATABASE odkbuild OWNER TO odkbuild; diff --git a/opendatakit-build/etc/init.d/opendatakit-build b/opendatakit-build/etc/init.d/opendatakit-build new file mode 100755 index 0000000..214b56f --- /dev/null +++ b/opendatakit-build/etc/init.d/opendatakit-build @@ -0,0 +1,22 @@ +#!/sbin/openrc-run + +description="OpenDataKit Build docker container" + +depend() { + need docker net postgres + use dns logger netmount +} + +start() { + /usr/bin/docker run -d --rm \ + --name opendatakit-build \ + -h opendatakit-build \ + --link postgres \ + -p 127.0.0.1:8016:8016 \ + -v /srv/opendatakit-build/conf/config.yml:/srv/odkbuild/config.yml \ + opendatakit-build +} + +stop() { + /usr/bin/docker stop opendatakit-build +} diff --git a/opendatakit-build/etc/nginx/conf.d/opendatakit-build.conf b/opendatakit-build/etc/nginx/conf.d/opendatakit-build.conf new file mode 100644 index 0000000..3f656b0 --- /dev/null +++ b/opendatakit-build/etc/nginx/conf.d/opendatakit-build.conf @@ -0,0 +1,11 @@ +server { + listen [::]:8816 ipv6only=off; + listen [::]:8416 ssl http2 ipv6only=off; + + access_log /var/log/nginx/opendatakit-build.access.log; + error_log /var/log/nginx/opendatakit-build.error.log; + + location / { + proxy_pass http://127.0.0.1:8016; + } +} diff --git a/opendatakit-build/srv/opendatakit-build/conf/config.yml b/opendatakit-build/srv/opendatakit-build/conf/config.yml new file mode 100644 index 0000000..44b9832 --- /dev/null +++ b/opendatakit-build/srv/opendatakit-build/conf/config.yml @@ -0,0 +1,8 @@ +development: + cookie_secret: ${ODKBUILD_COOKIE_SECRET} + cookie_ssl_only: false + database: + host: postgres + database: odkbuild + user: odkbuild + password: ${ODKBUILD_PWD} diff --git a/opendatakit/etc/init.d/opendatakit b/opendatakit/etc/init.d/opendatakit index 49b037e..a7371d7 100755 --- a/opendatakit/etc/init.d/opendatakit +++ b/opendatakit/etc/init.d/opendatakit @@ -1,6 +1,6 @@ #!/sbin/openrc-run -description="OpenDataKit docker container" +description="OpenDataKit Aggregate docker container" depend() { need docker net postgres