Revert long naming for OpenDataKit Build

This commit is contained in:
Disassembler 2018-04-21 23:06:16 +02:00
parent e02745c89c
commit 53b470118d
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
12 changed files with 69 additions and 69 deletions

View File

@ -1,23 +0,0 @@
#!/bin/sh
SOURCE_DIR=$(realpath $(dirname "${0}"))/odkbuild
# Check prerequisites
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
docker image ls | grep -q ruby || $(realpath $(dirname "${0}"))/ruby.sh
service postgres start
# Build Docker container
docker build -t odkbuild ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/odkbuild /etc/init.d/odkbuild
rc-update -u
# 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/odkbuild/conf
envsubst <${SOURCE_DIR}/srv/odkbuild/conf/config.yml >/srv/odkbuild/conf/config.yml
docker run --rm -h odkbuild --link postgres -v /srv/odkbuild/conf/config.yml:/srv/odkbuild/config.yml -w /srv/odkbuild odkbuild rake db:migrate

View File

@ -1,4 +0,0 @@
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;

View File

@ -1,28 +0,0 @@
#!/sbin/openrc-run
description="OpenDataKit Build docker container"
depend() {
need docker postgres
}
start() {
/usr/bin/docker run -d --rm \
--name odkbuild \
-h odkbuild \
--link postgres \
-v /srv/odkbuild/conf/config.yml:/srv/odkbuild/config.yml \
odkbuild
}
start_post() {
/usr/bin/spotter-appmgr register-proxy odkbuild
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy odkbuild
}
stop() {
/usr/bin/docker stop odkbuild
}

View File

@ -1,8 +0,0 @@
development:
cookie_secret: ${ODKBUILD_COOKIE_SECRET}
cookie_ssl_only: false
database:
host: postgres
database: odkbuild
user: odkbuild
password: ${ODKBUILD_PWD}

23
opendatakit-build.sh Executable file
View File

@ -0,0 +1,23 @@
#!/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
service postgres start
# Build Docker container
docker build -t opendatakit-build ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/opendatakit-build /etc/init.d/opendatakit-build
rc-update -u
# Create databases
export OPENDATAKITBUILD_PWD=$(head -c 18 /dev/urandom | base64)
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql
# Configure OpenDataKit Build
export OPENDATAKITBUILD_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/opendatakit-build/config.yml -w /srv/opendatakit-build opendatakit-build rake db:migrate

View File

@ -20,18 +20,18 @@ RUN \
&& 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 \
&& git clone --depth 1 https://github.com/opendatakit/build /srv/opendatakit-build \
# Install Ruby dependencies
&& cd /srv/odkbuild \
&& cd /srv/opendatakit-build \
&& bundle install --without test \
&& rake deploy:build \
# Create OS user
&& addgroup -S -g 8017 odkbuild \
&& adduser -S -u 8017 -h /srv/odkbuild -s /bin/false -g odkbuild -G odkbuild odkbuild \
&& chown -R odkbuild:odkbuild /srv/odkbuild \
&& adduser -S -u 8017 -h /srv/opendatakit-build -s /bin/false -g odkbuild -G odkbuild odkbuild \
&& chown -R odkbuild:odkbuild /srv/opendatakit-build \
# Cleanup
&& apk --no-cache del .deps \
&& find /srv/odkbuild -name '.git*' -exec rm -rf {} + \
&& find /srv/opendatakit-build -name '.git*' -exec rm -rf {} + \
&& rm -rf /root/.bundle
RUN \

View File

@ -0,0 +1,4 @@
CREATE ROLE opendatakitbuild NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN ENCRYPTED PASSWORD '${OPENDATAKITBUILD_PWD}';
CREATE DATABASE opendatakitbuild;
REVOKE ALL ON DATABASE opendatakitbuild FROM public;
ALTER DATABASE opendatakitbuild OWNER TO opendatakitbuild;

View File

@ -1,6 +1,6 @@
#!/bin/execlineb -P
cd /srv/odkbuild
cd /srv/opendatakit-build
fdmove -c 2 1
s6-setuidgid 8017:8017
bundle exec rackup config.ru -o 0.0.0.0 -p 8080

View File

@ -0,0 +1,28 @@
#!/sbin/openrc-run
description="OpenDataKit Build docker container"
depend() {
need docker postgres
}
start() {
/usr/bin/docker run -d --rm \
--name opendatakit-build \
-h opendatakit-build \
--link postgres \
-v /srv/opendatakit-build/conf/config.yml:/srv/opendatakit-build/config.yml \
opendatakit-build
}
start_post() {
/usr/bin/spotter-appmgr register-proxy opendatakit-build
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy opendatakit-build
}
stop() {
/usr/bin/docker stop opendatakit-build
}

View File

@ -0,0 +1,8 @@
development:
cookie_secret: ${OPENDATAKITBUILD_COOKIE_SECRET}
cookie_ssl_only: false
database:
host: postgres
database: opendatakitbuild
user: opendatakitbuild
password: ${OPENDATAKITBUILD_PWD}