From 2485af55b00029aa4b6a9af27bacd5c7ff54bbae Mon Sep 17 00:00:00 2001 From: Marko Bocevski Date: Wed, 16 Dec 2020 20:22:35 +0100 Subject: [PATCH 1/4] Add a ckan alias command for 2.7 and 2.8 so it can be forward-compatible with 2.9 --- images/ckan/2.7/Dockerfile | 3 +++ images/ckan/2.7/setup/bin/ckan | 14 ++++++++++++++ images/ckan/2.8/Dockerfile | 3 +++ images/ckan/2.8/setup/bin/ckan | 14 ++++++++++++++ 4 files changed, 34 insertions(+) create mode 100755 images/ckan/2.7/setup/bin/ckan create mode 100755 images/ckan/2.8/setup/bin/ckan diff --git a/images/ckan/2.7/Dockerfile b/images/ckan/2.7/Dockerfile index ec72633..fecaf1e 100644 --- a/images/ckan/2.7/Dockerfile +++ b/images/ckan/2.7/Dockerfile @@ -166,6 +166,9 @@ RUN rm -rf /srv/app/wheels /srv/app/ext_wheels # Copy necessary scripts COPY setup/app ${APP_DIR} +# Copy the alias script for paster to be ckan so it's compatible with 2.9 +COPY setup/bin/ckan /usr/bin/ckan + # Create entrypoint directory for children image scripts ONBUILD RUN mkdir docker-entrypoint.d diff --git a/images/ckan/2.7/setup/bin/ckan b/images/ckan/2.7/setup/bin/ckan new file mode 100755 index 0000000..0389541 --- /dev/null +++ b/images/ckan/2.7/setup/bin/ckan @@ -0,0 +1,14 @@ +#!/bin/bash +# CKAN <2.9 uses paster and the ckan plugin for paster which expects the configuration to be passed +# to a subcommand, example: paster --plugin=ckan datastore -c /srv/app/production.ini set-permissions +# CKAN >2.9 ckan CLI command expects the configuration option as the second and third parameter +# Example: ckan -c /srv/app/production.ini datastore set-permissions +# +# Shift the two arguments so that we can move them to the end of the argument list +# ckan -c /srv/app/production.ini datastore set-permissions +# becomes +# paster --plugin datastore set-permissions -c /srv/app/production.ini +config_switch=$1 +config_file=$2 +shift 2 +paster --plugin=ckan "$@" "$config_switch" "$config_file" diff --git a/images/ckan/2.8/Dockerfile b/images/ckan/2.8/Dockerfile index a7d9e24..4ec6e6c 100644 --- a/images/ckan/2.8/Dockerfile +++ b/images/ckan/2.8/Dockerfile @@ -160,6 +160,9 @@ RUN rm -rf /srv/app/wheels /srv/app/ext_wheels # Copy necessary scripts COPY setup/app ${APP_DIR} +# Copy the alias script for paster to be ckan so it's compatible with 2.9 +COPY setup/bin/ckan /usr/bin/ckan + # Create entrypoint directory for children image scripts ONBUILD RUN mkdir docker-entrypoint.d diff --git a/images/ckan/2.8/setup/bin/ckan b/images/ckan/2.8/setup/bin/ckan new file mode 100755 index 0000000..0389541 --- /dev/null +++ b/images/ckan/2.8/setup/bin/ckan @@ -0,0 +1,14 @@ +#!/bin/bash +# CKAN <2.9 uses paster and the ckan plugin for paster which expects the configuration to be passed +# to a subcommand, example: paster --plugin=ckan datastore -c /srv/app/production.ini set-permissions +# CKAN >2.9 ckan CLI command expects the configuration option as the second and third parameter +# Example: ckan -c /srv/app/production.ini datastore set-permissions +# +# Shift the two arguments so that we can move them to the end of the argument list +# ckan -c /srv/app/production.ini datastore set-permissions +# becomes +# paster --plugin datastore set-permissions -c /srv/app/production.ini +config_switch=$1 +config_file=$2 +shift 2 +paster --plugin=ckan "$@" "$config_switch" "$config_file" From 7f974b661591aa6c6b0864bbbe3c22ebfe3b8d8c Mon Sep 17 00:00:00 2001 From: Marko Bocevski Date: Wed, 16 Dec 2020 20:40:10 +0100 Subject: [PATCH 2/4] Add ckan command alias for focal images --- images/ckan/2.7/Dockerfile.focal | 3 +++ images/ckan/2.8/Dockerfile.focal | 3 +++ 2 files changed, 6 insertions(+) diff --git a/images/ckan/2.7/Dockerfile.focal b/images/ckan/2.7/Dockerfile.focal index b1a6500..5d69961 100644 --- a/images/ckan/2.7/Dockerfile.focal +++ b/images/ckan/2.7/Dockerfile.focal @@ -213,6 +213,9 @@ RUN rm -rf /srv/app/wheels /srv/app/ext_wheels # Copy necessary scripts COPY setup/app ${APP_DIR} +# Copy the alias script for paster to be ckan so it's compatible with 2.9 +COPY setup/bin/ckan /usr/bin/ckan + # Create entrypoint directory for children image scripts ONBUILD RUN mkdir docker-entrypoint.d diff --git a/images/ckan/2.8/Dockerfile.focal b/images/ckan/2.8/Dockerfile.focal index 5fc56f2..c539e08 100644 --- a/images/ckan/2.8/Dockerfile.focal +++ b/images/ckan/2.8/Dockerfile.focal @@ -198,6 +198,9 @@ RUN rm -rf /srv/app/wheels /srv/app/ext_wheels # Copy necessary scripts COPY setup/app ${APP_DIR} +# Copy the alias script for paster to be ckan so it's compatible with 2.9 +COPY setup/bin/ckan /usr/bin/ckan + # Create entrypoint directory for children image scripts ONBUILD RUN mkdir docker-entrypoint.d From 9247cb4acb843034742183123f39c88276de886b Mon Sep 17 00:00:00 2001 From: Marko Bocevski Date: Wed, 16 Dec 2020 20:43:36 +0100 Subject: [PATCH 3/4] Reorder the argument list for the ckan alias command --- images/ckan/2.7/setup/bin/ckan | 9 +++++---- images/ckan/2.8/setup/bin/ckan | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/images/ckan/2.7/setup/bin/ckan b/images/ckan/2.7/setup/bin/ckan index 0389541..abf14e7 100755 --- a/images/ckan/2.7/setup/bin/ckan +++ b/images/ckan/2.7/setup/bin/ckan @@ -4,11 +4,12 @@ # CKAN >2.9 ckan CLI command expects the configuration option as the second and third parameter # Example: ckan -c /srv/app/production.ini datastore set-permissions # -# Shift the two arguments so that we can move them to the end of the argument list +# Shift three arguments so that we can reorder the argument list # ckan -c /srv/app/production.ini datastore set-permissions # becomes -# paster --plugin datastore set-permissions -c /srv/app/production.ini +# paster --plugin datastore -c /srv/app/production.ini set-permissions config_switch=$1 config_file=$2 -shift 2 -paster --plugin=ckan "$@" "$config_switch" "$config_file" +subcommand=$3 +shift 3 +paster --plugin=ckan "$subcommand" "$config_switch" "$config_file" "$@" diff --git a/images/ckan/2.8/setup/bin/ckan b/images/ckan/2.8/setup/bin/ckan index 0389541..abf14e7 100755 --- a/images/ckan/2.8/setup/bin/ckan +++ b/images/ckan/2.8/setup/bin/ckan @@ -4,11 +4,12 @@ # CKAN >2.9 ckan CLI command expects the configuration option as the second and third parameter # Example: ckan -c /srv/app/production.ini datastore set-permissions # -# Shift the two arguments so that we can move them to the end of the argument list +# Shift three arguments so that we can reorder the argument list # ckan -c /srv/app/production.ini datastore set-permissions # becomes -# paster --plugin datastore set-permissions -c /srv/app/production.ini +# paster --plugin datastore -c /srv/app/production.ini set-permissions config_switch=$1 config_file=$2 -shift 2 -paster --plugin=ckan "$@" "$config_switch" "$config_file" +subcommand=$3 +shift 3 +paster --plugin=ckan "$subcommand" "$config_switch" "$config_file" "$@" From b593510f53364bf55be68d02189d6341b4805f6c Mon Sep 17 00:00:00 2001 From: Marko Bocevski Date: Wed, 16 Dec 2020 20:48:57 +0100 Subject: [PATCH 4/4] mend Reorder the argument list for the ckan alias command --- images/ckan/2.7/setup/bin/ckan | 2 +- images/ckan/2.8/setup/bin/ckan | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/images/ckan/2.7/setup/bin/ckan b/images/ckan/2.7/setup/bin/ckan index abf14e7..f2e03dd 100755 --- a/images/ckan/2.7/setup/bin/ckan +++ b/images/ckan/2.7/setup/bin/ckan @@ -7,7 +7,7 @@ # Shift three arguments so that we can reorder the argument list # ckan -c /srv/app/production.ini datastore set-permissions # becomes -# paster --plugin datastore -c /srv/app/production.ini set-permissions +# paster --plugin=ckan datastore -c /srv/app/production.ini set-permissions config_switch=$1 config_file=$2 subcommand=$3 diff --git a/images/ckan/2.8/setup/bin/ckan b/images/ckan/2.8/setup/bin/ckan index abf14e7..f2e03dd 100755 --- a/images/ckan/2.8/setup/bin/ckan +++ b/images/ckan/2.8/setup/bin/ckan @@ -7,7 +7,7 @@ # Shift three arguments so that we can reorder the argument list # ckan -c /srv/app/production.ini datastore set-permissions # becomes -# paster --plugin datastore -c /srv/app/production.ini set-permissions +# paster --plugin=ckan datastore -c /srv/app/production.ini set-permissions config_switch=$1 config_file=$2 subcommand=$3