From 53b470118d9fd53343fa2002239c291ce8f7f17b Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sat, 21 Apr 2018 23:06:16 +0200 Subject: [PATCH] Revert long naming for OpenDataKit Build --- odkbuild.sh | 23 --------------- odkbuild/createdb.sql | 4 --- odkbuild/etc/init.d/odkbuild | 28 ------------------- odkbuild/srv/odkbuild/conf/config.yml | 8 ------ opendatakit-build.sh | 23 +++++++++++++++ {odkbuild => opendatakit-build}/Dockerfile | 10 +++---- opendatakit-build/createdb.sql | 4 +++ .../docker/etc/services.d/.s6-svscan/finish | 0 .../docker/etc/services.d/build2xlsform/run | 0 .../docker/etc/services.d/odkbuild/run | 2 +- .../etc/init.d/opendatakit-build | 28 +++++++++++++++++++ .../srv/opendatakit-build/conf/config.yml | 8 ++++++ 12 files changed, 69 insertions(+), 69 deletions(-) delete mode 100755 odkbuild.sh delete mode 100644 odkbuild/createdb.sql delete mode 100755 odkbuild/etc/init.d/odkbuild delete mode 100644 odkbuild/srv/odkbuild/conf/config.yml create mode 100755 opendatakit-build.sh rename {odkbuild => opendatakit-build}/Dockerfile (84%) create mode 100644 opendatakit-build/createdb.sql rename {odkbuild => opendatakit-build}/docker/etc/services.d/.s6-svscan/finish (100%) rename {odkbuild => opendatakit-build}/docker/etc/services.d/build2xlsform/run (100%) rename {odkbuild => opendatakit-build}/docker/etc/services.d/odkbuild/run (80%) create mode 100755 opendatakit-build/etc/init.d/opendatakit-build create mode 100644 opendatakit-build/srv/opendatakit-build/conf/config.yml diff --git a/odkbuild.sh b/odkbuild.sh deleted file mode 100755 index 58f2b89..0000000 --- a/odkbuild.sh +++ /dev/null @@ -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 diff --git a/odkbuild/createdb.sql b/odkbuild/createdb.sql deleted file mode 100644 index 315bad6..0000000 --- a/odkbuild/createdb.sql +++ /dev/null @@ -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; diff --git a/odkbuild/etc/init.d/odkbuild b/odkbuild/etc/init.d/odkbuild deleted file mode 100755 index c42670b..0000000 --- a/odkbuild/etc/init.d/odkbuild +++ /dev/null @@ -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 -} diff --git a/odkbuild/srv/odkbuild/conf/config.yml b/odkbuild/srv/odkbuild/conf/config.yml deleted file mode 100644 index 44b9832..0000000 --- a/odkbuild/srv/odkbuild/conf/config.yml +++ /dev/null @@ -1,8 +0,0 @@ -development: - cookie_secret: ${ODKBUILD_COOKIE_SECRET} - cookie_ssl_only: false - database: - host: postgres - database: odkbuild - user: odkbuild - password: ${ODKBUILD_PWD} diff --git a/opendatakit-build.sh b/opendatakit-build.sh new file mode 100755 index 0000000..7d9ecdc --- /dev/null +++ b/opendatakit-build.sh @@ -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 diff --git a/odkbuild/Dockerfile b/opendatakit-build/Dockerfile similarity index 84% rename from odkbuild/Dockerfile rename to opendatakit-build/Dockerfile index a9a849a..df9aef9 100644 --- a/odkbuild/Dockerfile +++ b/opendatakit-build/Dockerfile @@ -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 \ diff --git a/opendatakit-build/createdb.sql b/opendatakit-build/createdb.sql new file mode 100644 index 0000000..1b73f2b --- /dev/null +++ b/opendatakit-build/createdb.sql @@ -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; diff --git a/odkbuild/docker/etc/services.d/.s6-svscan/finish b/opendatakit-build/docker/etc/services.d/.s6-svscan/finish similarity index 100% rename from odkbuild/docker/etc/services.d/.s6-svscan/finish rename to opendatakit-build/docker/etc/services.d/.s6-svscan/finish diff --git a/odkbuild/docker/etc/services.d/build2xlsform/run b/opendatakit-build/docker/etc/services.d/build2xlsform/run similarity index 100% rename from odkbuild/docker/etc/services.d/build2xlsform/run rename to opendatakit-build/docker/etc/services.d/build2xlsform/run diff --git a/odkbuild/docker/etc/services.d/odkbuild/run b/opendatakit-build/docker/etc/services.d/odkbuild/run similarity index 80% rename from odkbuild/docker/etc/services.d/odkbuild/run rename to opendatakit-build/docker/etc/services.d/odkbuild/run index eba81ae..9f19f5d 100755 --- a/odkbuild/docker/etc/services.d/odkbuild/run +++ b/opendatakit-build/docker/etc/services.d/odkbuild/run @@ -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 diff --git a/opendatakit-build/etc/init.d/opendatakit-build b/opendatakit-build/etc/init.d/opendatakit-build new file mode 100755 index 0000000..c33bbac --- /dev/null +++ b/opendatakit-build/etc/init.d/opendatakit-build @@ -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 +} 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..8462a11 --- /dev/null +++ b/opendatakit-build/srv/opendatakit-build/conf/config.yml @@ -0,0 +1,8 @@ +development: + cookie_secret: ${OPENDATAKITBUILD_COOKIE_SECRET} + cookie_ssl_only: false + database: + host: postgres + database: opendatakitbuild + user: opendatakitbuild + password: ${OPENDATAKITBUILD_PWD}