Merge pull request #8 from keitaroinc/2.8.2
CKAN docker image for 2.8.2
This commit is contained in:
commit
6aee14e1a4
|
@ -5,7 +5,7 @@ FROM alpine:3.8 as ckanbuild
|
|||
|
||||
# Set CKAN version to build
|
||||
ENV GIT_URL=https://github.com/ckan/ckan.git
|
||||
ENV GIT_BRANCH=ckan-2.8.1
|
||||
ENV GIT_BRANCH=ckan-2.8.2
|
||||
|
||||
# Set src dirs
|
||||
ENV SRC_DIR=/srv/app/src
|
||||
|
@ -28,6 +28,7 @@ RUN apk add --no-cache \
|
|||
libtool \
|
||||
musl-dev \
|
||||
pcre-dev \
|
||||
pcre \
|
||||
python-dev
|
||||
|
||||
# Create the src directory
|
||||
|
@ -54,7 +55,7 @@ ENV APP_DIR=/srv/app
|
|||
ENV SRC_DIR=/srv/app/src
|
||||
ENV PIP_SRC=${SRC_DIR}
|
||||
ENV CKAN_SITE_URL=http://localhost:5000
|
||||
ENV CKAN__PLUGINS image_view text_view recline_view datastore datapusher envvars
|
||||
ENV CKAN__PLUGINS envvars image_view text_view recline_view datastore datapusher
|
||||
|
||||
WORKDIR ${APP_DIR}
|
||||
|
||||
|
@ -66,6 +67,7 @@ RUN apk add --no-cache git \
|
|||
postgresql-client \
|
||||
python \
|
||||
libmagic \
|
||||
pcre \
|
||||
apache2-utils && \
|
||||
# Create SRC_DIR
|
||||
mkdir -p ${SRC_DIR}
|
||||
|
|
|
@ -5,6 +5,7 @@ import psycopg2
|
|||
import urllib2
|
||||
import re
|
||||
|
||||
import time
|
||||
|
||||
ckan_ini = os.environ.get('CKAN_INI', '/srv/app/production.ini')
|
||||
|
||||
|
@ -12,6 +13,8 @@ RETRY = 5
|
|||
|
||||
def check_db_connection(retry=None):
|
||||
|
||||
print '[prerun] Start check_db_connection...'
|
||||
|
||||
if retry is None:
|
||||
retry = RETRY
|
||||
elif retry == 0:
|
||||
|
@ -33,6 +36,8 @@ def check_db_connection(retry=None):
|
|||
|
||||
def check_solr_connection(retry=None):
|
||||
|
||||
print '[prerun] Start check_solr_connection...'
|
||||
|
||||
if retry is None:
|
||||
retry = RETRY
|
||||
elif retry == 0:
|
||||
|
@ -51,16 +56,22 @@ def check_solr_connection(retry=None):
|
|||
time.sleep(10)
|
||||
check_solr_connection(retry = retry - 1)
|
||||
else:
|
||||
eval(connection.read())
|
||||
|
||||
import re
|
||||
conn_info = connection.read()
|
||||
conn_info = re.sub(r'"zkConnected":true', '"zkConnected":True', conn_info)
|
||||
eval(conn_info)
|
||||
|
||||
def init_db():
|
||||
|
||||
db_command = ['paster', '--plugin=ckan', 'db',
|
||||
'init', '-c', ckan_ini]
|
||||
print '[prerun] Initializing or upgrading db - start'
|
||||
print '[prerun] Start init_db...'
|
||||
|
||||
db_command = ['paster', '--plugin=ckan', 'db', 'init', '-c', ckan_ini]
|
||||
|
||||
print '[prerun] Initializing or upgrading db - start using paster db init'
|
||||
try:
|
||||
# run init scripts
|
||||
subprocess.check_output(db_command, stderr=subprocess.STDOUT)
|
||||
|
||||
print '[prerun] Initializing or upgrading db - end'
|
||||
except subprocess.CalledProcessError, e:
|
||||
if 'OperationalError' in e.output:
|
||||
|
@ -72,10 +83,12 @@ def init_db():
|
|||
else:
|
||||
print e.output
|
||||
raise e
|
||||
|
||||
print '[prerun] Initializing or upgrading db - finish'
|
||||
|
||||
def create_sysadmin():
|
||||
|
||||
print '[prerun] Start create_sysadmin...'
|
||||
|
||||
name = os.environ.get('CKAN_SYSADMIN_NAME')
|
||||
password = os.environ.get('CKAN_SYSADMIN_PASSWORD')
|
||||
email = os.environ.get('CKAN_SYSADMIN_EMAIL')
|
||||
|
@ -108,7 +121,6 @@ def create_sysadmin():
|
|||
subprocess.call(command)
|
||||
print '[prerun] Made user {0} a sysadmin'.format(name)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
maintenance = os.environ.get('MAINTENANCE_MODE', '').lower() == 'true'
|
||||
|
@ -120,3 +132,4 @@ if __name__ == '__main__':
|
|||
check_solr_connection()
|
||||
init_db()
|
||||
create_sysadmin()
|
||||
#time.sleep(60000) # don't end the prerun script to allow container dock and debug
|
||||
|
|
Loading…
Reference in New Issue