Add installation script + Dockerfile for OpenDataKit Build, closes #170
This commit is contained in:
parent
6bec5b5e55
commit
580a0258a7
@ -96,6 +96,11 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="c" id="opendatakit-build">
|
||||
<h2><a href="#"><img src="img/ODK.png" alt="Open Data Kit" title="Open Data Kit">Open Data Kit Build</a></h2>
|
||||
<p><strong>Sběr dat s pomocí smartphone</strong>.<br>Aplikace pro návrh formulářů</p>
|
||||
</div>
|
||||
|
||||
<div class="c" id="openmapkit">
|
||||
<h2><a href="#"><img src="img/OMK.png" alt="Open Map Kit" title="Open Map Kit">Open Data Kit</a></h2>
|
||||
<p><strong>Sběr dat s pomocí smartphone</strong>.<br>
|
||||
|
32
opendatakit-build.sh
Executable file
32
opendatakit-build.sh
Executable file
@ -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/"
|
34
opendatakit-build/Dockerfile
Normal file
34
opendatakit-build/Dockerfile
Normal file
@ -0,0 +1,34 @@
|
||||
FROM ruby
|
||||
MAINTAINER Disassembler <disassembler@dasm.cz>
|
||||
|
||||
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"]
|
4
opendatakit-build/createdb.sql
Normal file
4
opendatakit-build/createdb.sql
Normal file
@ -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;
|
22
opendatakit-build/etc/init.d/opendatakit-build
Executable file
22
opendatakit-build/etc/init.d/opendatakit-build
Executable file
@ -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
|
||||
}
|
11
opendatakit-build/etc/nginx/conf.d/opendatakit-build.conf
Normal file
11
opendatakit-build/etc/nginx/conf.d/opendatakit-build.conf
Normal file
@ -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;
|
||||
}
|
||||
}
|
8
opendatakit-build/srv/opendatakit-build/conf/config.yml
Normal file
8
opendatakit-build/srv/opendatakit-build/conf/config.yml
Normal file
@ -0,0 +1,8 @@
|
||||
development:
|
||||
cookie_secret: ${ODKBUILD_COOKIE_SECRET}
|
||||
cookie_ssl_only: false
|
||||
database:
|
||||
host: postgres
|
||||
database: odkbuild
|
||||
user: odkbuild
|
||||
password: ${ODKBUILD_PWD}
|
@ -1,6 +1,6 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
description="OpenDataKit docker container"
|
||||
description="OpenDataKit Aggregate docker container"
|
||||
|
||||
depend() {
|
||||
need docker net postgres
|
||||
|
Loading…
Reference in New Issue
Block a user