Skip to content

Commit dca1d00

Browse files
committed
Enable harvester in datagov
1 parent 78b5505 commit dca1d00

5 files changed

Lines changed: 91 additions & 3 deletions

File tree

.docker-compose.datagov-theme.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ services:
55
image: viderum/ckan-cloud-docker:ckan-latest-datagov-theme
66
build:
77
args:
8+
EXTRA_PACKAGES: supervisor cron
9+
EXTRA_FILESYSTEM: "./overrides/datagov/filesystem/"
10+
ROOT_INIT: |
11+
mkdir -p /var/log/supervisor
12+
chown ckan:ckan /var/log/supervisor
813
POST_INSTALL: |
914
install_standard_ckan_extension_github ckan/ckanext-spatial ckanext-spatial &&\
1015
install_standard_ckan_extension_github ckan/ckanext-xloader ckanext-xloader &&\
@@ -16,12 +21,15 @@ services:
1621
install_standard_ckan_extension_github GSA/ckanext-geodatagov ckanext-geodatagov &&\
1722
install_standard_ckan_extension_github ViderumGlobal/USMetadata ckanext-usmetadata
1823
POST_DOCKER_BUILD: |
19-
mkdir -p /var/tmp/ckan/dynamic_menu
24+
mkdir -p /var/tmp/ckan/dynamic_menu &&\
25+
mkdir -p /var/log/ckan/std/
2026
CKAN_INIT: |
2127
ckan-paster --plugin=ckanext-archiver archiver init -c "CKAN_CONFIG/production.ini"
2228
ckan-paster --plugin=ckanext-report report initdb -c "CKAN_CONFIG/production.ini"
2329
ckan-paster --plugin=ckanext-harvest harvester initdb -c "CKAN_CONFIG/production.ini"
2430
cp /var/lib/ckan/main.css /usr/lib/ckan/venv/src/ckan/ckan/public/base/css/main.min.css || true
31+
crontab /etc/crontab-harvester
32+
service supervisor start
2533
environment:
2634
- CKAN_CONFIG_TEMPLATE_PREFIX=datagov-theme-
2735
jobs:

ckan/Dockerfile

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
FROM debian:jessie
44

5+
ARG EXTRA_PACKAGES
6+
57
# Install required system packages
68
RUN apt-get -q -y update \
79
&& DEBIAN_FRONTEND=noninteractive apt-get -q -y upgrade \
@@ -22,27 +24,30 @@ RUN apt-get -q -y update \
2224
vim \
2325
wget \
2426
redis-tools \
27+
${EXTRA_PACKAGES} \
2528
&& apt-get -q clean \
2629
&& rm -rf /var/lib/apt/lists/*
2730

31+
2832
# Define environment variables
2933
ENV CKAN_HOME /usr/lib/ckan
3034
ENV CKAN_VENV $CKAN_HOME/venv
3135
ENV CKAN_CONFIG /etc/ckan
3236
ENV CKAN_STORAGE_PATH=/var/lib/ckan
37+
ENV CKAN_LOGS_PATH=/var/log/ckan
3338

3439
# Create ckan user
3540
RUN useradd -r -u 900 -m -c "ckan account" -d $CKAN_HOME -s /bin/false ckan
3641

3742
# Setup virtual environment for CKAN
38-
RUN mkdir -p $CKAN_VENV $CKAN_CONFIG $CKAN_STORAGE_PATH && \
43+
RUN mkdir -p $CKAN_VENV $CKAN_CONFIG $CKAN_STORAGE_PATH $CKAN_LOGS_PATH && \
3944
virtualenv $CKAN_VENV && \
4045
ln -s $CKAN_VENV/bin/pip /usr/local/bin/ckan-pip &&\
4146
ln -s $CKAN_VENV/bin/paster /usr/local/bin/ckan-paster
4247

4348
# Setup CKAN
4449
RUN ckan-pip install -U pip &&\
45-
chown -R ckan:ckan $CKAN_HOME $CKAN_VENV $CKAN_CONFIG $CKAN_STORAGE_PATH
50+
chown -R ckan:ckan $CKAN_HOME $CKAN_VENV $CKAN_CONFIG $CKAN_STORAGE_PATH $CKAN_LOGS_PATH
4651

4752
USER ckan
4853

@@ -78,6 +83,18 @@ RUN . /post_install_functions.sh && eval "${POST_DOCKER_BUILD}"
7883
ARG CKAN_INIT
7984
RUN echo "${CKAN_INIT}" | sed s@CKAN_CONFIG@${CKAN_CONFIG}@g > ${CKAN_CONFIG}/ckan_extra_init.sh
8085

86+
USER root
87+
88+
# Extra files in the filesystem
89+
ARG EXTRA_FILESYSTEM
90+
COPY ${EXTRA_FILESYSTEM} /
91+
92+
# Initialization that should be done as root
93+
ARG ROOT_INIT
94+
RUN eval "${ROOT_INIT}"
95+
96+
USER ckan
97+
8198
ENTRYPOINT ["/ckan-entrypoint.sh"]
8299

83100
EXPOSE 5000
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# m h dom mon dow command
2+
*/15 * * * * /usr/local/bin/ckan-paster --plugin=ckanext-harvest harvester run --config=/etc/ckan/production.ini
3+
0 5 * * * /usr/local/bin/ckan-paster --plugin=ckanext-harvest harvester clean_harvest_log --config=/etc/ckan/production.ini
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; ===============================
2+
; ckan harvester
3+
; ===============================
4+
[program:ckan_gather_consumer]
5+
6+
command=/usr/local/bin/ckan-paster --plugin=ckanext-harvest harvester gather_consumer --config=/etc/ckan/production.ini
7+
8+
; user that owns virtual environment.
9+
user=ckan
10+
11+
numprocs=1
12+
stdout_logfile=/var/log/ckan/std/gather_consumer.log
13+
stderr_logfile=/var/log/ckan/std/gather_consumer.log
14+
autostart=true
15+
autorestart=true
16+
startsecs=10
17+
18+
[program:ckan_fetch_consumer]
19+
20+
command=/usr/local/bin/ckan-paster --plugin=ckanext-harvest harvester fetch_consumer --config=/etc/ckan/production.ini
21+
22+
; user that owns virtual environment.
23+
user=ckan
24+
25+
numprocs=1
26+
stdout_logfile=/var/log/ckan/std/fetch_consumer.log
27+
stderr_logfile=/var/log/ckan/std/fetch_consumer.log
28+
autostart=true
29+
autorestart=true
30+
startsecs=10
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; supervisor config file
2+
3+
[unix_http_server]
4+
file=/var/tmp/supervisord.sock
5+
chmod=0770
6+
chown=ckan:ckan
7+
8+
9+
[supervisord]
10+
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
11+
pidfile=/var/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
12+
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
13+
14+
; the below section must remain in the config file for RPC
15+
; (supervisorctl/web interface) to work, additional interfaces may be
16+
; added by defining them in separate rpcinterface: sections
17+
[rpcinterface:supervisor]
18+
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
19+
20+
[supervisorctl]
21+
serverurl=unix:///var/tmp/supervisor.sock
22+
23+
; The [include] section can just contain the "files" setting. This
24+
; setting can list multiple files (separated by whitespace or
25+
; newlines). It can also contain wildcards. The filenames are
26+
; interpreted as relative to this file. Included files *cannot*
27+
; include files themselves.
28+
29+
[include]
30+
files = /etc/supervisor/conf.d/*.conf

0 commit comments

Comments
 (0)