LXCize ODK Build setup

This commit is contained in:
Disassembler 2018-09-13 21:52:38 +02:00
parent 57ecc71ebe
commit 44546c4816
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
3 changed files with 15 additions and 23 deletions

View File

@ -1,26 +1,24 @@
#!/bin/sh #!/bin/sh
set -e set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/opendatakit-build SOURCE_DIR=$(realpath $(dirname "${0}"))/setup
# Check prerequisites # Check prerequisites
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh [ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
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 # Create databases
export OPENDATAKITBUILD_PWD=$(head -c 18 /dev/urandom | base64) export OPENDATAKITBUILD_PWD=$(head -c 18 /dev/urandom | base64)
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql envsubst <${SOURCE_DIR}/createdb.sql | lxc-attach -u 5432 -g 5432 postgres psql
# Configure OpenDataKit Build # Configure OpenDataKit Build
export OPENDATAKITBUILD_COOKIE_SECRET=$(head -c 8 /dev/urandom | hexdump -e '"%x"') export OPENDATAKITBUILD_COOKIE_SECRET=$(head -c 8 /dev/urandom | hexdump -e '"%x"')
mkdir -p /srv/opendatakit-build/conf mkdir -p /srv/opendatakit-build/conf
envsubst <${SOURCE_DIR}/srv/opendatakit-build/conf/config.yml >/srv/opendatakit-build/conf/config.yml 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 lxc-execute opendatakit-build -- sh -c 'cd /srv/opendatakit-build; rake db:migrate'
# Install service
cp ${SOURCE_DIR}/etc/init.d/opendatakit-build /etc/init.d/opendatakit-build
rc-update -u
# Stop services required for build # Stop services required for build
service postgres stop [ ! -z ${STOP_POSTGRES} ] && service postgres stop

View File

@ -1,19 +1,13 @@
#!/sbin/openrc-run #!/sbin/openrc-run
description="OpenDataKit Build docker container" description="OpenDataKit Build container"
depend() { depend() {
need docker postgres need cgroups postgres
} }
start() { start() {
/usr/bin/docker run -d --rm \ lxc-start opendatakit-build
--name opendatakit-build \
-h opendatakit-build \
--link postgres \
-v /etc/ssl/services.pem:/usr/local/share/ca-certificates/services.crt \
-v /srv/opendatakit-build/conf/config.yml:/srv/opendatakit-build/config.yml \
opendatakit-build
} }
start_post() { start_post() {
@ -25,5 +19,5 @@ stop_pre() {
} }
stop() { stop() {
/usr/bin/docker stop opendatakit-build lxc-stop opendatakit-build
} }

View File

@ -19,8 +19,8 @@ ${SOURCE_DIR}/cts/setup.sh
${SOURCE_DIR}/frontlinesms/setup.sh ${SOURCE_DIR}/frontlinesms/setup.sh
${SOURCE_DIR}/gnuhealth/setup.sh ${SOURCE_DIR}/gnuhealth/setup.sh
${SOURCE_DIR}/kanboard/setup.sh ${SOURCE_DIR}/kanboard/setup.sh
#${SOURCE_DIR}/opendatakit/setup.sh ${SOURCE_DIR}/opendatakit/setup.sh
#${SOURCE_DIR}/opendatakit-build/setup.sh ${SOURCE_DIR}/opendatakit-build/setup.sh
#${SOURCE_DIR}/openmapkit/setup.sh #${SOURCE_DIR}/openmapkit/setup.sh
#${SOURCE_DIR}/pandora/setup.sh #${SOURCE_DIR}/pandora/setup.sh
#${SOURCE_DIR}/sahana/setup.sh #${SOURCE_DIR}/sahana/setup.sh