From c054be6dac9ca88961908c579e1c16421c33fc1a Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sun, 25 Mar 2018 22:55:15 +0200 Subject: [PATCH] Adjust CKAN for spotter-appmgr --- ckan-datapusher/Dockerfile | 4 ++-- .../srv/ckan-datapusher/conf/datapusher_settings.py | 2 +- ckan.sh | 11 +++-------- ckan/Dockerfile | 2 +- ckan/etc/init.d/ckan | 9 ++++----- ckan/etc/nginx/conf.d/ckan.conf | 11 ----------- ckan/srv/ckan/conf/ckan.ini | 4 ++-- ckan/srv/ckan/update-ip.sh | 4 ---- ckan/srv/ckan/update-url.sh | 6 ++++++ 9 files changed, 19 insertions(+), 34 deletions(-) delete mode 100644 ckan/etc/nginx/conf.d/ckan.conf delete mode 100755 ckan/srv/ckan/update-ip.sh create mode 100644 ckan/srv/ckan/update-url.sh diff --git a/ckan-datapusher/Dockerfile b/ckan-datapusher/Dockerfile index 0b9a2f8..febe4bf 100644 --- a/ckan-datapusher/Dockerfile +++ b/ckan-datapusher/Dockerfile @@ -41,7 +41,7 @@ RUN \ && patch -p0 /srv/ckan/conf/ckan.ini cp ${SOURCE_DIR}/srv/ckan/conf/who.ini /srv/ckan/conf/who.ini -cp ${SOURCE_DIR}/srv/ckan/update-ip.sh /srv/ckan/update-ip.sh -/srv/ckan/update-ip.sh +cp ${SOURCE_DIR}/srv/ckan/update-url.sh /srv/ckan/update-url.sh # Set "production values" (increases performance) only if the DEBUG environment variable is not set if [ ${DEBUG:-0} -eq 0 ]; then @@ -58,12 +57,8 @@ cp ${SOURCE_DIR}/etc/init.d/ckan /etc/init.d/ckan rc-update add ckan service ckan start -# Create nginx app definition -cp ${SOURCE_DIR}/etc/nginx/conf.d/ckan.conf /etc/nginx/conf.d/ckan.conf -service nginx reload - # Install cron job cp ${SOURCE_DIR}/etc/periodic/hourly/ckan /etc/periodic/hourly/ckan -# Add portal application definition -portal-app-manager ckan "https://{host}:8403/" "${CKAN_ADMIN_USER}" "${CKAN_ADMIN_PWD}" +# Add application definition +spotter-appmgr add-app ckan "https://ckan.{host}/" "${CKAN_ADMIN_USER}" "${CKAN_ADMIN_PWD}" diff --git a/ckan/Dockerfile b/ckan/Dockerfile index b995208..c46a0f3 100644 --- a/ckan/Dockerfile +++ b/ckan/Dockerfile @@ -48,7 +48,7 @@ RUN \ && rm -rf /root/.cache VOLUME ["/etc/ckan", "/srv/ckan/storage"] -EXPOSE 8003 +EXPOSE 8080 USER ckan CMD ["paster", "serve", "/etc/ckan/ckan.ini"] diff --git a/ckan/etc/init.d/ckan b/ckan/etc/init.d/ckan index b648f33..b5a1330 100755 --- a/ckan/etc/init.d/ckan +++ b/ckan/etc/init.d/ckan @@ -8,10 +8,6 @@ depend() { after ckan-datapusher redis solr } -start_pre() { - /srv/ckan/update-ip.sh -} - start() { /usr/bin/docker run -d --rm \ --name ckan \ @@ -22,12 +18,15 @@ start() { --link redis \ --link solr \ --link ckan-datapusher \ - -p 127.0.0.1:8003:8003 \ -v /srv/ckan/conf:/etc/ckan \ -v /srv/ckan/data:/srv/ckan/storage \ ckan } +start_post() { + /usr/local/bin/spotter-appmgr update-hosts ckan +} + stop() { /usr/bin/docker stop ckan } diff --git a/ckan/etc/nginx/conf.d/ckan.conf b/ckan/etc/nginx/conf.d/ckan.conf deleted file mode 100644 index a149bd9..0000000 --- a/ckan/etc/nginx/conf.d/ckan.conf +++ /dev/null @@ -1,11 +0,0 @@ -server { - listen [::]:8803 ipv6only=off; - listen [::]:8403 ssl http2 ipv6only=off; - - access_log /var/log/nginx/ckan.access.log; - error_log /var/log/nginx/ckan.error.log; - - location / { - proxy_pass http://127.0.0.1:8003; - } -} diff --git a/ckan/srv/ckan/conf/ckan.ini b/ckan/srv/ckan/conf/ckan.ini index 020b8cf..89ce3b9 100644 --- a/ckan/srv/ckan/conf/ckan.ini +++ b/ckan/srv/ckan/conf/ckan.ini @@ -19,7 +19,7 @@ debug = true [server:main] use = egg:Paste#http host = 0.0.0.0 -port = 8003 +port = 8080 [app:main] use = egg:ckan @@ -177,7 +177,7 @@ ckan.max_image_size = 10 # Make sure you have set up the DataStore ckan.datapusher.formats = csv xls xlsx tsv application/csv application/vnd.ms-excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet -ckan.datapusher.url = http://ckan-datapusher:8004/ +ckan.datapusher.url = http://ckan-datapusher:8080/ #ckan.datapusher.assume_task_stale_after = 3600 # Resource Proxy settings diff --git a/ckan/srv/ckan/update-ip.sh b/ckan/srv/ckan/update-ip.sh deleted file mode 100755 index 1eabfa3..0000000 --- a/ckan/srv/ckan/update-ip.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -URL=$(ip route get 1 | awk '{print $NF;exit}') -sed -i "s|^ckan\.site_url.*|ckan.site_url = https://${URL}:8403|" /srv/ckan/conf/ckan.ini diff --git a/ckan/srv/ckan/update-url.sh b/ckan/srv/ckan/update-url.sh new file mode 100644 index 0000000..056f930 --- /dev/null +++ b/ckan/srv/ckan/update-url.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +HOST="${1}" +[ "${2}" != "443" ] && HOST="${1}:${2}" + +sed -i "s|^ckan\.site_url.*|ckan.site_url = https://${HOST}|" /srv/ckan/conf/ckan.ini