Alpinize CKAN
This commit is contained in:
parent
56794033e0
commit
3b6c8471fe
48
ckan.sh
48
ckan.sh
@ -1,7 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
SOURCE_DIR=$(realpath $(dirname "${0}"))/ckan
|
||||
# Requires: Postgres, Redis, Solr, CKAN-Datapusher
|
||||
SOURCE_DIR=$(realpath $(dirname "${0}"))
|
||||
|
||||
# Check and install linked Docker containers
|
||||
docker images | grep -q postgres || ${SOURCE_DIR}/postgres.sh
|
||||
docker images | grep -q redis || ${SOURCE_DIR}/redis.sh
|
||||
docker images | grep -q solr || ${SOURCE_DIR}/solr.sh
|
||||
docker images | grep -q ckan-datastore || ${SOURCE_DIR}/ckan-datastore.sh
|
||||
|
||||
SOURCE_DIR=${SOURCE_DIR}/ckan
|
||||
|
||||
# Build Docker container
|
||||
docker build -t ckan ${SOURCE_DIR}
|
||||
@ -12,16 +19,17 @@ export CKAN_DS_PWD=$(head -c 18 /dev/urandom | base64)
|
||||
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql
|
||||
|
||||
# Configure CKAN Solr core
|
||||
docker exec solr solr create -c ckan
|
||||
docker exec solr solr create -p 8983 -c ckan
|
||||
cp ${SOURCE_DIR}/srv/solr/data/ckan/conf/schema.xml /srv/solr/data/ckan/conf/schema.xml
|
||||
cp ${SOURCE_DIR}/srv/solr/data/ckan/conf/solrconfig.xml /srv/solr/data/ckan/conf/solrconfig.xml
|
||||
chown 8983:8983 /srv/solr/data/ckan/conf/schema.xml
|
||||
systemctl restart solr
|
||||
service solr restart
|
||||
|
||||
# Configure CKAN
|
||||
export CKAN_SECRET=$(head -c 18 /dev/urandom | base64)
|
||||
export CKAN_UUID=$(cat /proc/sys/kernel/random/uuid)
|
||||
mkdir -p /srv/ckan/{conf,data}
|
||||
mkdir -p /srv/ckan/conf
|
||||
mkdir /srv/ckan/data
|
||||
envsubst <${SOURCE_DIR}/srv/ckan/conf/ckan.ini >/srv/ckan/conf/ckan.ini
|
||||
cp ${SOURCE_DIR}/srv/ckan/conf/who.ini /srv/ckan/conf/who.ini
|
||||
chown -R 8003:8003 /srv/ckan/data
|
||||
@ -43,28 +51,20 @@ export CKAN_ADMIN_EMAIL="admin@example.com"
|
||||
envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i postgres psql ckan
|
||||
|
||||
# Configure CKAN service
|
||||
cp ${SOURCE_DIR}/lib/systemd/system/ckan.service /lib/systemd/system/ckan.service
|
||||
systemctl daemon-reload
|
||||
systemctl enable ckan
|
||||
systemctl start ckan
|
||||
cp ${SOURCE_DIR}/etc/init.d/ckan /etc/init.d/ckan
|
||||
rc-update add ckan boot
|
||||
service ckan start
|
||||
|
||||
# Create nginx app definition
|
||||
cp ${SOURCE_DIR}/etc/nginx/apps/ckan /etc/nginx/apps/ckan
|
||||
cp ${SOURCE_DIR}/etc/nginx/conf.d/ckan.conf /etc/nginx/conf.d/ckan.conf
|
||||
|
||||
|
||||
# Create uwsgi and nginx app definition
|
||||
cp ${SOURCE_DIR}/etc/uwsgi/apps-available/ckan.ini /etc/uwsgi/apps-available/ckan.ini
|
||||
cp ${SOURCE_DIR}/etc/uwsgi/apps-available/ckan-datapusher.ini /etc/uwsgi/apps-available/ckan-datapusher.ini
|
||||
ln -s /etc/uwsgi/apps-available/ckan.ini /etc/uwsgi/apps-enabled/ckan.ini
|
||||
ln -s /etc/uwsgi/apps-available/ckan-datapusher.ini /etc/uwsgi/apps-enabled/ckan-datapusher.ini
|
||||
cp ${SOURCE_DIR}/etc/nginx/sites-available/ckan /etc/nginx/sites-available/ckan
|
||||
ln -s /etc/nginx/sites-available/ckan /etc/nginx/sites-enabled/ckan
|
||||
|
||||
# Restart services
|
||||
systemctl restart uwsgi
|
||||
systemctl restart nginx
|
||||
# Reload nginx configuration
|
||||
service nginx reload
|
||||
|
||||
# Install cron job
|
||||
cp ${SOURCE_DIR}/srv/ckan/cron-pageviews.sh /srv/ckan/cron-pageviews.sh
|
||||
cp ${SOURCE_DIR}/etc/cron.d/ckan /etc/cron.d/ckan
|
||||
#cp ${SOURCE_DIR}/srv/ckan/cron-pageviews.sh /srv/ckan/cron-pageviews.sh
|
||||
#cp ${SOURCE_DIR}/etc/cron.d/ckan /etc/cron.d/ckan
|
||||
|
||||
# Add portal application definition
|
||||
portal-app-manager ckan "https://{host}:8003/" "${CKAN_ADMIN_USER}" "${CKAN_ADMIN_PWD}"
|
||||
portal-app-manager ckan "https://{host}:8403/" "${CKAN_ADMIN_USER}" "${CKAN_ADMIN_PWD}"
|
||||
|
16
ckan/etc/init.d/ckan
Normal file
16
ckan/etc/init.d/ckan
Normal file
@ -0,0 +1,16 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
description="CKAN docker container"
|
||||
|
||||
depend() {
|
||||
need docker net postgres redis solr
|
||||
use dns logger netmount
|
||||
}
|
||||
|
||||
start() {
|
||||
/usr/bin/docker run -d --rm --name ckan --link=postgres --link=redis --link=solr -p 127.0.0.1:9003:8003 -v /srv/ckan/conf:/etc/ckan -v /srv/ckan/data:/srv/ckan/storage ckan
|
||||
}
|
||||
|
||||
stop() {
|
||||
/usr/bin/docker stop ckan
|
||||
}
|
9
ckan/etc/nginx/apps/ckan
Normal file
9
ckan/etc/nginx/apps/ckan
Normal file
@ -0,0 +1,9 @@
|
||||
access_log /var/log/nginx/ckan.access.log;
|
||||
error_log /var/log/nginx/ckan.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:9003;
|
||||
}
|
11
ckan/etc/nginx/conf.d/ckan.conf
Normal file
11
ckan/etc/nginx/conf.d/ckan.conf
Normal file
@ -0,0 +1,11 @@
|
||||
server {
|
||||
listen 8003;
|
||||
listen [::]:8003;
|
||||
include apps/ckan;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8403 ssl http2;
|
||||
listen [::]:8403 ssl http2;
|
||||
include apps/ckan;
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
server {
|
||||
listen 8003 ssl http2;
|
||||
listen [::]:8003 ssl http2;
|
||||
|
||||
access_log /var/log/nginx/ckan.access.log;
|
||||
error_log /var/log/nginx/ckan.error.log;
|
||||
|
||||
location / {
|
||||
uwsgi_pass unix:///run/uwsgi/app/ckan/socket;
|
||||
include uwsgi_params;
|
||||
uwsgi_param SCRIPT_NAME '';
|
||||
uwsgi_param UWSGI_SCHEME $scheme;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 127.0.0.1:8098;
|
||||
listen [::1]:8098;
|
||||
|
||||
access_log /var/log/nginx/ckan-datapusher.access.log;
|
||||
error_log /var/log/nginx/ckan-datapusher.error.log;
|
||||
|
||||
location / {
|
||||
uwsgi_pass unix:///run/uwsgi/app/ckan-datapusher/socket;
|
||||
include uwsgi_params;
|
||||
uwsgi_param SCRIPT_NAME '';
|
||||
uwsgi_param UWSGI_SCHEME $scheme;
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
[uwsgi]
|
||||
uid = ckan
|
||||
gid = ckan
|
||||
chown-socket = www-data:www-data
|
||||
chdir = /srv/ckan-datapusher
|
||||
home = /srv/ckan-datapusher
|
||||
master = false
|
||||
workers = 1
|
||||
disable-logging = true
|
||||
file = /etc/ckan/datapusher.wsgi
|
||||
enable-threads = true
|
@ -1,11 +0,0 @@
|
||||
[Unit]
|
||||
Description=CKAN Docker container
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/docker run --rm --name ckan --link=postgres --link=redis --link=solr -p 127.0.0.1:9003:8003 -v /srv/ckan/conf:/etc/ckan -v /srv/ckan/data:/srv/ckan/storage ckan
|
||||
ExecStop=/usr/bin/docker stop ckan
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user