CKAN + deps stup test

This commit is contained in:
Disassembler 2018-09-05 22:20:24 +02:00
parent 402ac5a469
commit 1b07ef795e
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
18 changed files with 69 additions and 97 deletions

View File

@ -22,7 +22,7 @@ RUN
COPY lxc COPY lxc
CMD /bin/s6-svscan /etc/services.d CMD s6-svscan /etc/services.d
LAYER activemq/delta0 LAYER activemq/delta0

View File

@ -1,12 +1,12 @@
#!/bin/sh #!/bin/sh
set -e set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/activemq/setup SOURCE_DIR=$(realpath $(dirname "${0}"))/setup
# Create service
cp ${SOURCE_DIR}/etc/init.d/activemq /etc/init.d/activemq
rc-update -u
# Configure ActiveMQ # Configure ActiveMQ
mkdir -p /srv/activemq/data mkdir -p /srv/activemq/data
chown -R 61616:61616 /srv/activemq/data chown -R 61616:61616 /srv/activemq/data
# Create service
cp ${SOURCE_DIR}/etc/init.d/activemq /etc/init.d/activemq
rc-update -u

View File

@ -1,6 +1,6 @@
#!/sbin/openrc-run #!/sbin/openrc-run
description="ActiveMQ docker container" description="ActiveMQ container"
depend() { depend() {
need lxc need lxc

View File

@ -41,4 +41,4 @@ VOLUME /etc/ssl/services.pem etc/ssl/services.pem
VOLUME /srv/ckan-datapusher/conf etc/ckan-datapusher VOLUME /srv/ckan-datapusher/conf etc/ckan-datapusher
VOLUME /srv/ckan-datapusher/data srv/ckan-datapusher/data VOLUME /srv/ckan-datapusher/data srv/ckan-datapusher/data
CMD /bin/s6-svscan /etc/services.d CMD s6-svscan /etc/services.d

View File

@ -1,14 +1,14 @@
#!/bin/sh #!/bin/sh
set -e set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/ckan-datapusher SOURCE_DIR=$(realpath $(dirname "${0}"))/setup
# Build Docker container
cp ${SOURCE_DIR}/etc/init.d/ckan-datapusher /etc/init.d/ckan-datapusher
rc-update -u
# Configure CKAN DataPusher # Configure CKAN DataPusher
mkdir -p /srv/ckan-datapusher/conf /srv/ckan-datapusher/data 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.wsgi /srv/ckan-datapusher/conf/datapusher.wsgi
cp ${SOURCE_DIR}/srv/ckan-datapusher/conf/datapusher_settings.py /srv/ckan-datapusher/conf/datapusher_settings.py 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 chown -R 8004:8004 /srv/ckan-datapusher/data
# Install service
cp ${SOURCE_DIR}/etc/init.d/ckan-datapusher /etc/init.d/ckan-datapusher
rc-update -u

View File

@ -1,21 +1,15 @@
#!/sbin/openrc-run #!/sbin/openrc-run
description="CKAN DataPusher docker container" description="CKAN DataPusher container"
depend() { depend() {
need docker need lxc
} }
start() { start() {
/usr/bin/docker run -d --rm \ lxc-start -n ckan-datapusher
--name ckan-datapusher \
-h ckan-datapusher \
-v /etc/ssl/services.pem:/etc/ssl/services.pem \
-v /srv/ckan-datapusher/conf:/etc/ckan-datapusher \
-v /srv/ckan-datapusher/data:/srv/ckan-datapusher/data \
ckan-datapusher
} }
stop() { stop() {
/usr/bin/docker stop ckan-datapusher lxc-stop -n ckan-datapusher
} }

View File

@ -52,4 +52,4 @@ COPY lxc
MOUNT /srv/ckan/conf etc/ckan MOUNT /srv/ckan/conf etc/ckan
MOUNT /srv/ckan/data srv/ckan/storage MOUNT /srv/ckan/data srv/ckan/storage
CMD /bin/s6-svscan /etc/services.d CMD s6-svscan /etc/services.d

View File

@ -1,24 +1,20 @@
#!/bin/sh #!/bin/sh
set -e set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/ckan SOURCE_DIR=$(realpath $(dirname "${0}"))/setup
# Check prerequisites # Check prerequisites
service postgres start service postgres start
service redis start service redis start
service solr start service solr start
# Install service
cp ${SOURCE_DIR}/etc/init.d/ckan /etc/init.d/ckan
rc-update -u
# Create database # Create database
export CKAN_PWD=$(head -c 18 /dev/urandom | base64) export CKAN_PWD=$(head -c 18 /dev/urandom | base64)
export CKAN_DS_PWD=$(head -c 18 /dev/urandom | base64) export CKAN_DS_PWD=$(head -c 18 /dev/urandom | base64)
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql
# Configure CKAN Solr core # Configure CKAN Solr core
docker exec solr solr create -p 8983 -c ckan lxc-execute -n 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/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 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 chown 8983:8983 /srv/solr/data/ckan/conf/schema.xml
@ -37,9 +33,9 @@ if [ ${DEBUG:-0} -eq 0 ]; then
fi fi
# Populate database # Populate database
docker run --rm -h ckan --link postgres --link redis --link solr -v /srv/ckan/conf:/etc/ckan -v /srv/ckan/data:/srv/ckan/storage ckan paster --plugin=ckan db init -c /etc/ckan/ckan.ini lxc-execute -n ckan -- paster --plugin=ckan db init -c /etc/ckan/ckan.ini
docker run --rm -h ckan --link postgres --link redis --link solr -v /srv/ckan/conf:/etc/ckan -v /srv/ckan/data:/srv/ckan/storage ckan paster --plugin=ckanext-spatial spatial initdb -c /etc/ckan/ckan.ini lxc-execute -n ckan -- paster --plugin=ckanext-spatial spatial initdb -c /etc/ckan/ckan.ini
docker run --rm -h ckan --link postgres --link redis --link solr -v /srv/ckan/conf:/etc/ckan -v /srv/ckan/data:/srv/ckan/storage ckan paster --plugin=ckan datastore set-permissions -c /etc/ckan/ckan.ini | docker exec -i postgres psql lxc-execute -n ckan -- paster --plugin=ckan datastore set-permissions -c /etc/ckan/ckan.ini | lxc-execute -n postgres -- psql
chown -R 8003:8003 /srv/ckan/data chown -R 8003:8003 /srv/ckan/data
# Create admin account # Create admin account
@ -55,6 +51,10 @@ vmmgr update-login ckan "${CKAN_ADMIN_USER}" "${CKAN_ADMIN_PWD}"
# Install cron job # Install cron job
cp ${SOURCE_DIR}/etc/periodic/hourly/ckan /etc/periodic/hourly/ckan cp ${SOURCE_DIR}/etc/periodic/hourly/ckan /etc/periodic/hourly/ckan
# Install service
cp ${SOURCE_DIR}/etc/init.d/ckan /etc/init.d/ckan
rc-update -u
# Stop services required for build # Stop services required for build
service solr stop service solr stop
service redis stop service redis stop

View File

@ -1,33 +1,23 @@
#!/sbin/openrc-run #!/sbin/openrc-run
description="CKAN docker container" description="CKAN container"
depend() { depend() {
need docker ckan-datapusher postfix postgres redis solr need lxc ckan-datapusher postgres redis solr
} }
start() { start() {
/usr/bin/docker run -d --rm \ lxc-start -n ckan
--name ckan \
-h ckan \
--link ckan-datapusher \
--link postfix \
--link postgres \
--link redis \
--link solr \
-v /srv/ckan/conf:/etc/ckan \
-v /srv/ckan/data:/srv/ckan/storage \
ckan
} }
start_post() { start_post() {
/usr/bin/vmmgr register-proxy ckan # /usr/bin/vmmgr register-proxy ckan
} }
stop_pre() { stop_pre() {
/usr/bin/vmmgr unregister-proxy ckan # /usr/bin/vmmgr unregister-proxy ckan
} }
stop() { stop() {
/usr/bin/docker stop ckan lxc-stop -n ckan
} }

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
if docker ps | grep -q 'ckan$'; then if docker ps | grep -q 'ckan$'; then
docker exec ckan paster --plugin=ckan tracking update -c /etc/ckan/ckan.ini >/dev/null lxc-execute -n ckan -- paster --plugin=ckan tracking update -c /etc/ckan/ckan.ini >/dev/null
docker exec ckan paster --plugin=ckan search-index rebuild -r -c /etc/ckan/ckan.ini >/dev/null lxc-execute -n ckan -- paster --plugin=ckan search-index rebuild -r -c /etc/ckan/ckan.ini >/dev/null
fi fi

View File

@ -1,17 +1,13 @@
#!/bin/sh #!/bin/sh
set -e set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/postgres SOURCE_DIR=$(realpath $(dirname "${0}"))/setup
# Build Docker container
cp ${SOURCE_DIR}/etc/init.d/postgres /etc/init.d/postgres
rc-update -u
# Create Postgres instance # Create Postgres instance
mkdir -p /srv/postgres/data mkdir -p /srv/postgres/data
chown -R 5432:5432 /srv/postgres/data chown -R 5432:5432 /srv/postgres/data
chmod 700 /srv/postgres/data chmod 700 /srv/postgres/data
docker run --rm --name postgres -h postgres -v /srv/postgres/data:/var/lib/postgresql postgres initdb -D /var/lib/postgresql lxc-execute -n postgres -- postgres initdb -D /var/lib/postgresql
# Configure Postgres # Configure Postgres
cp ${SOURCE_DIR}/srv/postgres/data/postgresql.conf /srv/postgres/data/postgresql.conf cp ${SOURCE_DIR}/srv/postgres/data/postgresql.conf /srv/postgres/data/postgresql.conf
@ -21,3 +17,7 @@ if [ ${DEBUG:-0} -eq 1 ]; then
sed -i 's/^#log_destination/log_destination/' /srv/postgres/data/postgresql.conf sed -i 's/^#log_destination/log_destination/' /srv/postgres/data/postgresql.conf
sed -i 's/^#log_statement/log_statement/' /srv/postgres/data/postgresql.conf sed -i 's/^#log_statement/log_statement/' /srv/postgres/data/postgresql.conf
fi fi
# Install service
cp ${SOURCE_DIR}/etc/init.d/postgres /etc/init.d/postgres
rc-update -u

View File

@ -1,23 +1,19 @@
#!/sbin/openrc-run #!/sbin/openrc-run
description="Postgres docker container" description="Postgres container"
depend() { depend() {
need docker need lxc
} }
start() { start() {
/usr/bin/docker run -d --rm \ lxc-start -n postgres
--name postgres \
-h postgres \
-v /srv/postgres/data:/var/lib/postgresql \
postgres
} }
start_post() { start_post() {
timeout -t 60 docker exec postgres sh -c 'until [ -e /var/run/postgresql/.s.PGSQL.5432 ]; do usleep 50000; done' ewaitfile 60 /var/lib/lxc/postgres/delta0/var/run/postgresql/.s.PGSQL.5432
} }
stop() { stop() {
/usr/bin/docker stop postgres lxc-stop -n postgres
} }

View File

@ -15,4 +15,4 @@ MOUNT /srv/redis/conf/redis.conf etc/redis.conf
MOUNT /srv/redis/data var/lib/redis MOUNT /srv/redis/data var/lib/redis
USER 6379 6379 USER 6379 6379
CMD /usr/bin/redis-server /etc/redis.conf CMD redis-server /etc/redis.conf

View File

@ -1,14 +1,13 @@
#!/bin/sh #!/bin/sh
set -e set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/redis SOURCE_DIR=$(realpath $(dirname "${0}"))/setup
# Build Docker container
docker build -t redis ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/redis /etc/init.d/redis
rc-update -u
# Configure Redis # Configure Redis
mkdir -p /srv/redis/conf /srv/redis/data mkdir -p /srv/redis/conf /srv/redis/data
cp ${SOURCE_DIR}/srv/redis/conf/redis.conf /srv/redis/conf/redis.conf cp ${SOURCE_DIR}/srv/redis/conf/redis.conf /srv/redis/conf/redis.conf
chown -R 6379:6379 /srv/redis/data chown -R 6379:6379 /srv/redis/data
# Install service
cp ${SOURCE_DIR}/etc/init.d/redis /etc/init.d/redis
rc-update -u

View File

@ -1,20 +1,15 @@
#!/sbin/openrc-run #!/sbin/openrc-run
description="Redis docker container" description="Redis container"
depend() { depend() {
need docker need lxc
} }
start() { start() {
/usr/bin/docker run -d --rm \ lxc-start -n redis
--name redis \
-h redis \
-v /srv/redis/conf/redis.conf:/etc/redis.conf \
-v /srv/redis/data:/var/lib/redis \
redis
} }
stop() { stop() {
/usr/bin/docker stop redis lxc-stop -n redis
} }

View File

@ -21,9 +21,12 @@ SCRIPT
# Copy basic configuration file to data location # Copy basic configuration file to data location
cp -p /opt/solr/server/solr/solr.xml /var/lib/solr/solr.xml cp -p /opt/solr/server/solr/solr.xml /var/lib/solr/solr.xml
# Make start/stop script visible globally
ln -s /opt/solr/bin/solr /usr/bin/solr
RUN RUN
MOUNT /srv/solr/data var/lib/solr MOUNT /srv/solr/data var/lib/solr
USER 8983 8983 USER 8983 8983
CMD /opt/solr/bin/solr start -f CMD solr start -f

View File

@ -1,15 +1,14 @@
#!/bin/sh #!/bin/sh
set -e set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/solr SOURCE_DIR=$(realpath $(dirname "${0}"))/setup
# Build Docker container
docker build -t solr ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/solr /etc/init.d/solr
rc-update -u
# Configure Solr # Configure Solr
mkdir -p /srv/solr/data mkdir -p /srv/solr/data
cp ${SOURCE_DIR}/srv/solr/data/solr.xml /srv/solr/data/solr.xml cp ${SOURCE_DIR}/srv/solr/data/solr.xml /srv/solr/data/solr.xml
cp ${SOURCE_DIR}/srv/solr/data/.solr.in.sh /srv/solr/data/.solr.in.sh cp ${SOURCE_DIR}/srv/solr/data/.solr.in.sh /srv/solr/data/.solr.in.sh
chown -R 8983:8983 /srv/solr/data chown -R 8983:8983 /srv/solr/data
# Install service
cp ${SOURCE_DIR}/etc/init.d/solr /etc/init.d/solr
rc-update -u

View File

@ -1,19 +1,15 @@
#!/sbin/openrc-run #!/sbin/openrc-run
description="Solr docker container" description="Solr container"
depend() { depend() {
need docker need lxc
} }
start() { start() {
/usr/bin/docker run -d --rm \ lxc-start -n solr
--name solr \
-h solr \
-v /srv/solr/data:/var/lib/solr \
solr
} }
stop() { stop() {
/usr/bin/docker stop solr lxc-stop -n solr
} }