From 12b7200f9e3e9c558d03b0296ffb68e6a0b7c979 Mon Sep 17 00:00:00 2001
From: Disassembler <disassembler@dasm.cz>
Date: Sun, 25 Mar 2018 23:16:06 +0200
Subject: [PATCH] Unify ODK Build naming and nginx configuration for
 spotter-appmgr

---
 opendatakit-build.sh                                  |  8 ++------
 opendatakit-build/Dockerfile                          |  2 +-
 opendatakit-build/docker/etc/services.d/odkbuild/run  |  2 +-
 opendatakit-build/etc/init.d/opendatakit-build        |  5 ++++-
 .../etc/nginx/conf.d/opendatakit-build.conf           | 11 -----------
 5 files changed, 8 insertions(+), 20 deletions(-)
 delete mode 100644 opendatakit-build/etc/nginx/conf.d/opendatakit-build.conf

diff --git a/opendatakit-build.sh b/opendatakit-build.sh
index 0cac8fc..11fda67 100755
--- a/opendatakit-build.sh
+++ b/opendatakit-build.sh
@@ -24,9 +24,5 @@ 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}:8417/"
+# Add application definition
+spotter-appmgr add-app opendatakit-build "https://opendatakit-build.{host}/"
diff --git a/opendatakit-build/Dockerfile b/opendatakit-build/Dockerfile
index 2b5f3b4..a9a849a 100644
--- a/opendatakit-build/Dockerfile
+++ b/opendatakit-build/Dockerfile
@@ -50,6 +50,6 @@ RUN \
 
 COPY docker/ /
 
-EXPOSE 8017
+EXPOSE 8080
 
 CMD ["s6-svscan", "/etc/services.d"]
diff --git a/opendatakit-build/docker/etc/services.d/odkbuild/run b/opendatakit-build/docker/etc/services.d/odkbuild/run
index c2d3468..eba81ae 100755
--- a/opendatakit-build/docker/etc/services.d/odkbuild/run
+++ b/opendatakit-build/docker/etc/services.d/odkbuild/run
@@ -3,4 +3,4 @@
 cd /srv/odkbuild
 fdmove -c 2 1
 s6-setuidgid 8017:8017
-bundle exec rackup config.ru -o 0.0.0.0 -p 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
index ba153c0..5a2828c 100755
--- a/opendatakit-build/etc/init.d/opendatakit-build
+++ b/opendatakit-build/etc/init.d/opendatakit-build
@@ -12,11 +12,14 @@ start() {
 	--name opendatakit-build \
 	-h opendatakit-build \
 	--link postgres \
-	-p 127.0.0.1:8017:8017 \
 	-v /srv/opendatakit-build/conf/config.yml:/srv/odkbuild/config.yml \
 	opendatakit-build
 }
 
+start_post() {
+	/usr/local/bin/spotter-appmgr update-hosts 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
deleted file mode 100644
index 3ee0a48..0000000
--- a/opendatakit-build/etc/nginx/conf.d/opendatakit-build.conf
+++ /dev/null
@@ -1,11 +0,0 @@
-server {
-    listen [::]:8817 ipv6only=off;
-    listen [::]:8417 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:8017;
-    }
-}