diff --git a/ckan-datapusher.sh b/ckan-datapusher.sh new file mode 100755 index 0000000..45c9931 --- /dev/null +++ b/ckan-datapusher.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +SOURCE_DIR=$(realpath $(dirname "${0}"))/ckan-datapusher + +# Build Docker container +docker build -t ckan-datapusher ${SOURCE_DIR} +cp ${SOURCE_DIR}/etc/init.d/ckan-datapusher /etc/init.d/ckan-datapusher +rc-update -u + +# Configure CKAN DataPusher +mkdir -p /srv/ckan-datapusher/conf /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 diff --git a/ckandp/Dockerfile b/ckan-datapusher/Dockerfile similarity index 59% rename from ckandp/Dockerfile rename to ckan-datapusher/Dockerfile index 9a2ca35..8fa2a45 100644 --- a/ckandp/Dockerfile +++ b/ckan-datapusher/Dockerfile @@ -17,24 +17,24 @@ RUN \ # Install build dependencies apk --no-cache add --virtual .deps build-base git libffi-dev libressl-dev libxml2-dev libxslt-dev py2-pip python2-dev \ # Install CKAN DataPusher - && mkdir -p /srv/ckandp \ - && cd /srv/ckandp \ + && 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' \ # Hackfix the X509_STORE_CTX wrapper - && sed -i 's/\[security\]//' /srv/ckandp/src/datapusher/requirements.txt \ - && pip install -r /srv/ckandp/src/datapusher/requirements.txt \ + && sed -i 's/\[security\]//' /srv/ckan-datapusher/src/datapusher/requirements.txt \ + && pip install -r /srv/ckan-datapusher/src/datapusher/requirements.txt \ # Create OS user && addgroup -S -g 8004 ckandp \ - && adduser -S -u 8004 -h /srv/ckandp -s /bin/false -g ckandp -G ckandp ckandp \ - && chown -R ckandp:ckandp /srv/ckandp \ + && adduser -S -u 8004 -h /srv/ckan-datapusher -s /bin/false -g ckandp -G ckandp ckandp \ + && chown -R ckandp:ckandp /srv/ckan-datapusher \ # Cleanup && apk --no-cache del .deps \ - && find /srv/ckandp/src -name '.git*' -exec rm -rf {} + \ + && find /srv/ckan-datapusher/src -name '.git*' -exec rm -rf {} + \ && rm -rf /root/.cache -VOLUME ["/etc/ckandp", "/srv/ckandp/data"] +VOLUME ["/etc/ckan-datapusher", "/srv/ckan-datapusher/data"] EXPOSE 8080 USER ckandp -CMD ["uwsgi", "--plugin", "python", "--http-socket", "0.0.0.0:8080", "--wsgi-file", "/etc/ckandp/datapusher.wsgi", "--enable-threads"] +CMD ["uwsgi", "--plugin", "python", "--http-socket", "0.0.0.0:8080", "--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..7e32871 --- /dev/null +++ b/ckan-datapusher/etc/init.d/ckan-datapusher @@ -0,0 +1,20 @@ +#!/sbin/openrc-run + +description="CKAN DataPusher docker container" + +depend() { + need docker +} + +start() { + /usr/bin/docker run -d --rm \ + --name ckan-datapusher \ + -h ckan-datapusher \ + -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-datapusher +} diff --git a/ckandp/srv/ckandp/conf/datapusher.wsgi b/ckan-datapusher/srv/ckan-datapusher/conf/datapusher.wsgi similarity index 64% rename from ckandp/srv/ckandp/conf/datapusher.wsgi rename to ckan-datapusher/srv/ckan-datapusher/conf/datapusher.wsgi index 1978874..ce39261 100644 --- a/ckandp/srv/ckandp/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/ckandp/datapusher_settings.py' +os.environ['JOB_CONFIG'] = '/etc/ckan-datapusher/datapusher_settings.py' web.init() import datapusher.jobs as jobs diff --git a/ckandp/srv/ckandp/conf/datapusher_settings.py b/ckan-datapusher/srv/ckan-datapusher/conf/datapusher_settings.py similarity index 77% rename from ckandp/srv/ckandp/conf/datapusher_settings.py rename to ckan-datapusher/srv/ckan-datapusher/conf/datapusher_settings.py index 9531f70..93d8d5f 100644 --- a/ckandp/srv/ckandp/conf/datapusher_settings.py +++ b/ckan-datapusher/srv/ckan-datapusher/conf/datapusher_settings.py @@ -10,7 +10,7 @@ PASSWORD = str(uuid.uuid4()) NAME = 'datapusher' -SQLALCHEMY_DATABASE_URI = 'sqlite:////srv/ckandp/data/jobs.db' +SQLALCHEMY_DATABASE_URI = 'sqlite:////srv/ckan-datapusher/data/jobs.db' HOST = '0.0.0.0' PORT = 8080 diff --git a/ckan.sh b/ckan.sh index 2035846..2ed65ca 100755 --- a/ckan.sh +++ b/ckan.sh @@ -3,7 +3,7 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/ckan # Check prerequisites -docker image ls | grep -q ckandp || $(realpath $(dirname "${0}"))/ckandp.sh +docker image ls | grep -q ckan-datapusher || $(realpath $(dirname "${0}"))/ckan-datapusher.sh docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh docker image ls | grep -q redis || $(realpath $(dirname "${0}"))/redis.sh diff --git a/ckan/etc/init.d/ckan b/ckan/etc/init.d/ckan index b07e216..a435be1 100755 --- a/ckan/etc/init.d/ckan +++ b/ckan/etc/init.d/ckan @@ -3,14 +3,14 @@ description="CKAN docker container" depend() { - need docker ckandp postfix postgres redis solr + need docker ckan-datapusher postfix postgres redis solr } start() { /usr/bin/docker run -d --rm \ --name ckan \ -h ckan \ - --link ckandp \ + --link ckan-datapusher \ --link postfix \ --link postgres \ --link redis \ diff --git a/ckan/srv/ckan/conf/ckan.ini b/ckan/srv/ckan/conf/ckan.ini index e5c67d9..8b0ca46 100644 --- a/ckan/srv/ckan/conf/ckan.ini +++ b/ckan/srv/ckan/conf/ckan.ini @@ -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://ckandp:8080/ +ckan.datapusher.url = http://ckan-datapusher:8080/ #ckan.datapusher.assume_task_stale_after = 3600 # Resource Proxy settings diff --git a/ckandp.sh b/ckandp.sh deleted file mode 100755 index c1b7dc5..0000000 --- a/ckandp.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -SOURCE_DIR=$(realpath $(dirname "${0}"))/ckandp - -# Build Docker container -docker build -t ckandp ${SOURCE_DIR} -cp ${SOURCE_DIR}/etc/init.d/ckandp /etc/init.d/ckandp -rc-update -u - -# Configure CKAN DataPusher -mkdir -p /srv/ckandp/conf /srv/ckandp/data -cp ${SOURCE_DIR}/srv/ckandp/conf/datapusher.wsgi /srv/ckandp/conf/datapusher.wsgi -cp ${SOURCE_DIR}/srv/ckandp/conf/datapusher_settings.py /srv/ckandp/conf/datapusher_settings.py -chown -R 8004:8004 /srv/ckandp/data diff --git a/ckandp/etc/init.d/ckandp b/ckandp/etc/init.d/ckandp deleted file mode 100755 index 080211c..0000000 --- a/ckandp/etc/init.d/ckandp +++ /dev/null @@ -1,20 +0,0 @@ -#!/sbin/openrc-run - -description="CKAN DataPusher docker container" - -depend() { - need docker -} - -start() { - /usr/bin/docker run -d --rm \ - --name ckandp \ - -h ckandp \ - -v /srv/ckandp/conf:/etc/ckandp \ - -v /srv/ckandp/data:/srv/ckandp/data \ - ckandp -} - -stop() { - /usr/bin/docker stop ckandp -}