diff --git a/README.md b/README.md index 4ec4d13..cc42d7d 100644 --- a/README.md +++ b/README.md @@ -64,5 +64,5 @@ vi 00-install.sh | Solr | 8983 | N/A | | Sahana | 8001 | 8401 | | CKAN | 8003 | 8403 | -| CKAN Datapusher | 8004 | 8404 | +| CKAN Datapusher | 8004 | N/A | | OpenMapKit | 8007 | 8407 | diff --git a/ckan-datapusher.sh b/ckan-datapusher.sh new file mode 100755 index 0000000..0e7abfa --- /dev/null +++ b/ckan-datapusher.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +SOURCE_DIR=${SOURCE_DIR}/ckan-datapusher + +# Build Docker container +docker build -t ckan-datapusher ${SOURCE_DIR} + +# Configure CKAN DataPusher +mkdir -p /srv/ckan-datapusher/conf +mkdir /srv/ckan-datapusher/data +cp ${SOURCE_DIR}/srv/ckan-datapusher/conf/datapusher.wsgi /srv/ckan-datapusher/conf/datapusher.wsgi +cp ${SOURCE_DIR}/srv/ckan-datapusher/conf/datapusher_settings.py /srv/ckan-datapusher/conf/datapusher_settings.py +chown -R 8004:8004 /srv/ckan-datapusher/data + +# Configure CKAN DataPusher service +cp ${SOURCE_DIR}/etc/init.d/ckan-datapusher /etc/init.d/ckan-datapusher +rc-update add ckan-datapusher boot +service ckan-datapusher start + +# Create nginx app definition +cp ${SOURCE_DIR}/etc/nginx/apps/ckan-datapusher /etc/nginx/apps/ckan-datapusher +cp ${SOURCE_DIR}/etc/nginx/conf.d/ckan-datapusher.conf /etc/nginx/conf.d/ckan-datapusher.conf + +# Reload nginx configuration +service nginx reload diff --git a/ckan-datapusher/Dockerfile b/ckan-datapusher/Dockerfile new file mode 100644 index 0000000..a6e26dd --- /dev/null +++ b/ckan-datapusher/Dockerfile @@ -0,0 +1,27 @@ +FROM alpine:3.7 +MAINTAINER Disassembler + +RUN apk --no-cache add python2 + +RUN apk --no-cache add libxml2 libxslt + +RUN apk --no-cache add libffi libressl libxml2 libxslt uwsgi-python \ + && apk --no-cache add --virtual .deps build-base git libffi-dev libressl-dev libxml2-dev libxslt-dev py2-pip python2-dev \ + && mkdir -p /srv/ckan-datapusher \ + && cd /srv/ckan-datapusher \ + && pip install -U setuptools \ + && pip install -e 'git+https://github.com/ckan/datapusher.git#egg=datapusher' \ + && pip install -r /srv/ckan-datapusher/src/datapusher/requirements.txt \ + && addgroup -S -g 8004 ckan-datapusher \ + && adduser -S -u 8004 -h /srv/ckan-datapusher -s /bin/false -g ckan-datapusher -G ckan-datapusher ckan-datapusher \ + && chown -R ckan-datapusher:ckan-datapusher /srv/ckan-datapusher \ + && apk del .deps \ + && find /srv/ckan-datapusher/src -name '.git*' -exec rm -rf {} + \ + && rm -rf /root \ + && mkdir /root + +VOLUME ["/etc/ckan-datapusher", "/srv/ckan-datapusher/data"] +EXPOSE 8004 + +USER ckan-datapusher +CMD ["uwsgi", "--plugin", "python", "--http-socket", "0.0.0.0:8004", "--wsgi-file", "/etc/ckan-datapusher/datapusher.wsgi", "--enable-threads"] diff --git a/ckan-datapusher/etc/init.d/ckan-datapusher b/ckan-datapusher/etc/init.d/ckan-datapusher new file mode 100755 index 0000000..281dbfd --- /dev/null +++ b/ckan-datapusher/etc/init.d/ckan-datapusher @@ -0,0 +1,16 @@ +#!/sbin/openrc-run + +description="CKAN DataPusher docker container" + +depend() { + need docker net + use dns logger netmount +} + +start() { + /usr/bin/docker run -d --rm --name ckan-datapusher -p 127.0.0.1:9004:8004 -v /srv/ckan-datapusher/conf:/etc/ckan-datapusher -v /srv/ckan-datapusher/data:/srv/ckan-datapusher/data ckan-datapusher +} + +stop() { + /usr/bin/docker stop ckan +} diff --git a/ckan-datapusher/etc/nginx/apps/ckan-datapusher b/ckan-datapusher/etc/nginx/apps/ckan-datapusher new file mode 100644 index 0000000..2375dfe --- /dev/null +++ b/ckan-datapusher/etc/nginx/apps/ckan-datapusher @@ -0,0 +1,9 @@ +access_log /var/log/nginx/ckan-datapusher.access.log; +error_log /var/log/nginx/ckan-datapusher.error.log; + +location / { + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Host $host:$server_port; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://127.0.0.1:9004; +} diff --git a/ckan-datapusher/etc/nginx/conf.d/ckan-datapusher.conf b/ckan-datapusher/etc/nginx/conf.d/ckan-datapusher.conf new file mode 100644 index 0000000..44b2257 --- /dev/null +++ b/ckan-datapusher/etc/nginx/conf.d/ckan-datapusher.conf @@ -0,0 +1,5 @@ +server { + listen 127.0.0.1:8004; + listen [::1]:8004; + include apps/ckan-datapusher; +} diff --git a/ckan/srv/ckan/conf/datapusher.wsgi b/ckan-datapusher/srv/ckan-datapusher/conf/datapusher.wsgi similarity index 64% rename from ckan/srv/ckan/conf/datapusher.wsgi rename to ckan-datapusher/srv/ckan-datapusher/conf/datapusher.wsgi index f8350ec..ce39261 100644 --- a/ckan/srv/ckan/conf/datapusher.wsgi +++ b/ckan-datapusher/srv/ckan-datapusher/conf/datapusher.wsgi @@ -3,7 +3,7 @@ import os import ckanserviceprovider.web as web -os.environ['JOB_CONFIG'] = '/etc/ckan/datapusher_settings.py' +os.environ['JOB_CONFIG'] = '/etc/ckan-datapusher/datapusher_settings.py' web.init() import datapusher.jobs as jobs diff --git a/ckan/srv/ckan/conf/datapusher_settings.py b/ckan-datapusher/srv/ckan-datapusher/conf/datapusher_settings.py similarity index 75% rename from ckan/srv/ckan/conf/datapusher_settings.py rename to ckan-datapusher/srv/ckan-datapusher/conf/datapusher_settings.py index dc7d53a..18a138d 100644 --- a/ckan/srv/ckan/conf/datapusher_settings.py +++ b/ckan-datapusher/srv/ckan-datapusher/conf/datapusher_settings.py @@ -10,10 +10,10 @@ PASSWORD = str(uuid.uuid4()) NAME = 'datapusher' -SQLALCHEMY_DATABASE_URI = 'sqlite:////srv/ckan-datapusher/jobs.db' +SQLALCHEMY_DATABASE_URI = 'sqlite:////srv/ckan-datapusher/data/jobs.db' HOST = '0.0.0.0' -PORT = 8098 +PORT = 8004 SSL_VERIFY = False FROM_EMAIL = 'ckan@spotter.ngo' diff --git a/ckan/serviceprovider-sslverify.patch b/ckan/serviceprovider-sslverify.patch deleted file mode 100644 index 4ddf13f..0000000 --- a/ckan/serviceprovider-sslverify.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -ruN orig/python2.7/site-packages/ckanserviceprovider/web.py lib/python2.7/site-packages/ckanserviceprovider/web.py ---- orig/python2.7/site-packages/ckanserviceprovider/web.py 2017-12-01 08:55:57.595353323 +0100 -+++ lib/python2.7/site-packages/ckanserviceprovider/web.py 2017-12-01 08:56:37.819592364 +0100 -@@ -733,6 +733,7 @@ - try: - result = requests.post( - result_url, -+ verify=False, - data=json.dumps(job_dict, cls=DatetimeJsonEncoder), - headers=headers) -