Skip to content

Commit

Permalink
Using new ENV-VAR names
Browse files Browse the repository at this point in the history
  • Loading branch information
Raul Hidalgo Caballero committed Jan 6, 2017
1 parent c741569 commit b05c43a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Expand Up @@ -5,8 +5,8 @@ MAINTAINER Open Knowledge

ENV CKAN_HOME /usr/lib/ckan/default
ENV CKAN_CONFIG /etc/ckan/default
ENV CKAN_DATA /var/lib/ckan
ENV SITE_URL http://localhost:5000
ENV CKAN_STORAGE_PATH /var/lib/ckan
ENV CKAN_SITE_URL http://localhost:5000

# Install required packages
RUN apt-get -q -y update && apt-get -q -y upgrade && DEBIAN_FRONTEND=noninteractive apt-get -q -y install \
Expand All @@ -18,7 +18,7 @@ RUN apt-get -q -y update && apt-get -q -y upgrade && DEBIAN_FRONTEND=noninteract
&& apt-get -q clean

# SetUp Virtual Environment CKAN
RUN mkdir -p $CKAN_HOME $CKAN_CONFIG $CKAN_DATA
RUN mkdir -p $CKAN_HOME $CKAN_CONFIG $CKAN_STORAGE_PATH
RUN virtualenv $CKAN_HOME
RUN ln -s $CKAN_HOME/bin/pip /usr/local/bin/ckan-pip
RUN ln -s $CKAN_HOME/bin/paster /usr/local/bin/ckan-paster
Expand Down
42 changes: 24 additions & 18 deletions contrib/docker/ckan-entrypoint.sh
@@ -1,13 +1,13 @@
#!/bin/sh
set -eu
set -e

# URL for the primary database, in the format expected by sqlalchemy (required
# unless linked to a container called 'db')
: ${DATABASE_URL:=}
: ${CKAN_SQLALCHEMY_URL:=}
# URL for solr (required unless linked to a container called 'solr')
: ${SOLR_URL:=}
: ${CKAN_SOLR_URL:=}
# URL for redis (required unless linked to a container called 'redis')
: ${REDIS_URL:=}
: ${CKAN_REDIS_URL:=}

CONFIG="${CKAN_CONFIG}/ckan.ini"

Expand All @@ -19,12 +19,18 @@ abort () {
write_config () {
ckan-paster make-config ckan "$CONFIG"

#export CKAN_SQLALCHEMY_URL=${CKAN_SQLALCHEMY_URL}
#export CKAN_SOLR_URL=${CKAN_SOLR_URL}
#export CKAN_SITE_URL=${CKAN_SITE_URL}
#export CKAN_REDIS_URL=${KAN_REDIS_URL}
#export CKAN_STORAGE_PATH=${CKAN_STORAGE_PATH}

ckan-paster --plugin=ckan config-tool "$CONFIG" -e \
"sqlalchemy.url = ${DATABASE_URL}" \
"solr_url = ${SOLR_URL}" \
"ckan.redis.url = ${REDIS_URL}" \
"ckan.storage_path = ${CKAN_DATA}" \
"ckan.site_url = ${SITE_URL}"
"sqlalchemy.url = ${CKAN_SQLALCHEMY_URL}" \
"solr_url = ${CKAN_SOLR_URL}" \
"ckan.redis.url = ${CKAN_REDIS_URL}" \
"ckan.storage_path = ${CKAN_STORAGE_PATH}" \
"ckan.site_url = ${CKAN_SITE_URL}"
}

link_postgres_url () {
Expand All @@ -51,21 +57,21 @@ link_redis_url () {
# If we don't already have a config file, bootstrap
if [ ! -e "$CONFIG" ]; then

if [ -z "$DATABASE_URL" ]; then
if ! DATABASE_URL=$(link_postgres_url); then
abort "ERROR: no DATABASE_URL specified and linked container called 'db' was not found"
if [ -z "$CKAN_SQLALCHEMY_URL" ]; then
if ! CKAN_SQLALCHEMY_URL=$(link_postgres_url); then
abort "ERROR: no CKAN_SQLALCHEMY_URL specified and linked container called 'db' was not found"
fi
fi

if [ -z "$SOLR_URL" ]; then
if ! SOLR_URL=$(link_solr_url); then
abort "ERROR: no SOLR_URL specified and linked container called 'solr' was not found"
if [ -z "$CKAN_SOLR_URL" ]; then
if ! CKAN_SOLR_URL=$(link_solr_url); then
abort "ERROR: no CKAN_SOLR_URL specified and linked container called 'solr' was not found"
fi
fi

if [ -z "$REDIS_URL" ]; then
if ! REDIS_URL=$(link_redis_url); then
abort "ERROR: no REDIS_URL specified and linked container called 'redis' was not found"
if [ -z "$CKAN_REDIS_URL" ]; then
if ! CKAN_REDIS_URL=$(link_redis_url); then
abort "ERROR: no CKAN_REDIS_URL specified and linked container called 'redis' was not found"
fi
fi

Expand Down

0 comments on commit b05c43a

Please sign in to comment.