From f9ebc0c41c1bda1bfac992d5687e15c81e2c5e80 Mon Sep 17 00:00:00 2001 From: amercader Date: Tue, 17 Oct 2023 12:21:50 +0200 Subject: [PATCH 1/4] Add step to copy init files Always copy the files in /docker-entrypoint.d automatically, otherwise users need to explicitly add a `COPY` step in the `ckan/Dockerfile`, which is confusing --- ckan/Dockerfile | 4 ++++ ckan/Dockerfile.dev | 4 +++- ckan/docker-entrypoint.d/README.md | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 ckan/docker-entrypoint.d/README.md diff --git a/ckan/Dockerfile b/ckan/Dockerfile index 8f0532e..5af0f60 100644 --- a/ckan/Dockerfile +++ b/ckan/Dockerfile @@ -5,6 +5,10 @@ ENV APP_DIR=/srv/app ENV TZ=UTC RUN echo ${TZ} > /etc/timezone + +# Copy custom initialization scripts +COPY docker-entrypoint.d/* /docker-entrypoint.d/ + # Make sure both files are not exactly the same RUN if ! [ /usr/share/zoneinfo/${TZ} -ef /etc/localtime ]; then \ cp /usr/share/zoneinfo/${TZ} /etc/localtime ;\ diff --git a/ckan/Dockerfile.dev b/ckan/Dockerfile.dev index 1720f71..b4cdc65 100644 --- a/ckan/Dockerfile.dev +++ b/ckan/Dockerfile.dev @@ -44,9 +44,11 @@ RUN if ! [ /usr/share/zoneinfo/${TZ} -ef /etc/localtime ]; then \ # Clone the extension(s) your are writing for your own project in the `src` folder # to get them mounted in this image at runtime +# Copy custom initialization scripts +COPY docker-entrypoint.d/* /docker-entrypoint.d/ + # Apply any patches needed to CKAN core or any of the built extensions (not the # runtime mounted ones) - COPY patches ${APP_DIR}/patches RUN for d in $APP_DIR/patches/*; do \ diff --git a/ckan/docker-entrypoint.d/README.md b/ckan/docker-entrypoint.d/README.md new file mode 100644 index 0000000..27fa292 --- /dev/null +++ b/ckan/docker-entrypoint.d/README.md @@ -0,0 +1,4 @@ +Use scripts in this folder to run extra initialization steps in your custom CKAN images. +Any file with `.sh` or `.py` extension will be executed just after the main initialization +script (`prerun.py`) is executed and just before the web server and supervisor processes are +started. From f653b0324de14e83d5fc0e26dc72c2ec714de4be Mon Sep 17 00:00:00 2001 From: amercader Date: Tue, 17 Oct 2023 12:39:03 +0200 Subject: [PATCH 2/4] Remove timezone commands They have been moved to ckan-docker-base https://github.com/ckan/ckan-docker-base/pull/30 --- ckan/Dockerfile | 10 ---------- ckan/Dockerfile.dev | 7 ------- 2 files changed, 17 deletions(-) diff --git a/ckan/Dockerfile b/ckan/Dockerfile index 5af0f60..83e6309 100644 --- a/ckan/Dockerfile +++ b/ckan/Dockerfile @@ -1,15 +1,5 @@ FROM ckan/ckan-base:2.10.1 -# Set up environment variables -ENV APP_DIR=/srv/app -ENV TZ=UTC -RUN echo ${TZ} > /etc/timezone - # Copy custom initialization scripts COPY docker-entrypoint.d/* /docker-entrypoint.d/ - -# Make sure both files are not exactly the same -RUN if ! [ /usr/share/zoneinfo/${TZ} -ef /etc/localtime ]; then \ - cp /usr/share/zoneinfo/${TZ} /etc/localtime ;\ - fi ; diff --git a/ckan/Dockerfile.dev b/ckan/Dockerfile.dev index b4cdc65..2997362 100644 --- a/ckan/Dockerfile.dev +++ b/ckan/Dockerfile.dev @@ -3,13 +3,6 @@ FROM ckan/ckan-dev:2.10.1 # Set up environment variables ENV APP_DIR=/srv/app -ENV TZ=UTC -RUN echo ${TZ} > /etc/timezone - -# Make sure both files are not exactly the same -RUN if ! [ /usr/share/zoneinfo/${TZ} -ef /etc/localtime ]; then \ - cp /usr/share/zoneinfo/${TZ} /etc/localtime ;\ - fi ; # Install any extensions needed by your CKAN instance # - Make sure to add the plugins to CKAN__PLUGINS in the .env file From 2e46f06280e2d1cc1f081e127baabc69545e16ca Mon Sep 17 00:00:00 2001 From: amercader Date: Tue, 17 Oct 2023 12:46:45 +0200 Subject: [PATCH 3/4] Apply patches in prod images as well --- ckan/Dockerfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ckan/Dockerfile b/ckan/Dockerfile index 83e6309..e4d4118 100644 --- a/ckan/Dockerfile +++ b/ckan/Dockerfile @@ -3,3 +3,15 @@ FROM ckan/ckan-base:2.10.1 # Copy custom initialization scripts COPY docker-entrypoint.d/* /docker-entrypoint.d/ + +# Apply any patches needed to CKAN core or any of the built extensions (not the +# runtime mounted ones) +COPY patches ${APP_DIR}/patches + +RUN for d in $APP_DIR/patches/*; do \ + if [ -d $d ]; then \ + for f in `ls $d/*.patch | sort -g`; do \ + cd $SRC_DIR/`basename "$d"` && echo "$0: Applying patch $f to $SRC_DIR/`basename $d`"; patch -p1 < "$f" ; \ + done ; \ + fi ; \ + done From c5b3981b39a39b4db454dd2d362e810d8cd9ca6d Mon Sep 17 00:00:00 2001 From: amercader Date: Tue, 17 Oct 2023 12:47:08 +0200 Subject: [PATCH 4/4] Review extensions installation guidance --- ckan/Dockerfile | 2 ++ ckan/Dockerfile.dev | 15 ++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ckan/Dockerfile b/ckan/Dockerfile index e4d4118..ea89105 100644 --- a/ckan/Dockerfile +++ b/ckan/Dockerfile @@ -1,5 +1,7 @@ FROM ckan/ckan-base:2.10.1 +# Install any extensions needed by your CKAN instance +# See Dockerfile.dev for more details and examples # Copy custom initialization scripts COPY docker-entrypoint.d/* /docker-entrypoint.d/ diff --git a/ckan/Dockerfile.dev b/ckan/Dockerfile.dev index 2997362..58daceb 100644 --- a/ckan/Dockerfile.dev +++ b/ckan/Dockerfile.dev @@ -1,16 +1,13 @@ FROM ckan/ckan-dev:2.10.1 - -# Set up environment variables -ENV APP_DIR=/srv/app - # Install any extensions needed by your CKAN instance # - Make sure to add the plugins to CKAN__PLUGINS in the .env file -# - Also make sure all extra configuration options are added to the CKAN config file (ckan.ini) -# This can be done by creating an overriding start_ckan_dev_development.sh file: -# (https://github.com/ckan/ckan-docker-base/blob/main/ckan-2.9/dev/setup/start_ckan_development.sh) ie: updating the 'ckan config-tool' lines -# For more on config-tool please see https://docs.ckan.org/en/latest/maintaining/cli.html#config-tool-tool-for-editing-options-in-a-ckan-config-file -# or using Crudini (https://github.com/pixelb/crudini) +# - Also make sure all provide all extra configuration options, either by: +# * Adding them to the .env file (check the ckanext-envvars syntax for env vars), or +# * Adding extra configuration scripts to /docker-entrypoint.d folder) to update +# the CKAN config file (ckan.ini) with the `ckan config-tool` command +# +# See README > Extending the base images for more details # # For instance: #