Skip to content

Commit

Permalink
Decouple datapusher from init scripts
Browse files Browse the repository at this point in the history
As discussed in ckan/ckan-docker#95

Remove datapusher from default plugin list env var and remove setup
commands from the entrypoint scripts
(start_ckan.sh/start_ckan_development.sh)

Sadly we still need the one to add a temporary value on the api token
config option, otherwise all `ckan` commands will fail, but at least we
only run it if datapusher is listed in CKAN__PLUGINS
  • Loading branch information
amercader committed Oct 17, 2023
1 parent 2124a84 commit f77c387
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ckan-2.10/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ENV GIT_URL=https://github.com/ckan/ckan.git
ENV GIT_BRANCH=${CKAN_VERSION}
# Customize these on the .env file if needed
ENV CKAN_SITE_URL=http://localhost:5000
ENV CKAN__PLUGINS image_view text_view recline_view datastore datapusher envvars
ENV CKAN__PLUGINS image_view text_view recline_view datastore envvars

# UWSGI options
ENV UWSGI_HARAKIRI=50
Expand Down
15 changes: 7 additions & 8 deletions ckan-2.10/base/setup/start_ckan.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/sh
#!/bin/bash

# Add ckan.datapusher.api_token to the CKAN config file (updated with corrected value later)
ckan config-tool $CKAN_INI ckan.datapusher.api_token=xxx
if [[ $CKAN__PLUGINS == *"datapusher"* ]]; then
# Add ckan.datapusher.api_token to the CKAN config file (updated with corrected value later)
echo "Setting a temporary value for ckan.datapusher.api_token"
ckan config-tool $CKAN_INI ckan.datapusher.api_token=xxx
fi

# Set up the Secret key used by Beaker and Flask
# This can be overriden using a CKAN___BEAKER__SESSION__SECRET env var
if grep -E "beaker.session.secret ?= ?$" ckan.ini
if grep -qE "beaker.session.secret ?= ?$" ckan.ini
then
echo "Setting beaker.session.secret in ini file"
ckan config-tool $CKAN_INI "beaker.session.secret=$(python3 -c 'import secrets; print(secrets.token_urlsafe())')"
Expand All @@ -18,9 +21,6 @@ fi
# Run the prerun script to init CKAN and create the default admin user
python3 prerun.py

echo "Set up ckan.datapusher.api_token in the CKAN config file"
ckan config-tool $CKAN_INI "ckan.datapusher.api_token=$(ckan -c $CKAN_INI user token add ckan_admin datapusher | tail -n 1 | tr -d '\t')"

# Run any startup scripts provided by images extending this one
if [[ -d "/docker-entrypoint.d" ]]
then
Expand All @@ -30,7 +30,6 @@ then
*.py) echo "$0: Running init file $f"; python3 "$f"; echo ;;
*) echo "$0: Ignoring $f (not an sh or py file)" ;;
esac
echo
done
fi

Expand Down
12 changes: 6 additions & 6 deletions ckan-2.10/dev/setup/start_ckan_development.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/sh

if [[ $CKAN__PLUGINS == *"datapusher"* ]]; then
# Add ckan.datapusher.api_token to the CKAN config file (updated with corrected value later)
echo "Setting a temporary value for ckan.datapusher.api_token"
ckan config-tool $CKAN_INI ckan.datapusher.api_token=xxx
fi

# Install any local extensions in the src_extensions volume
echo "Looking for local extensions to install..."
echo "Extension dir contents:"
Expand Down Expand Up @@ -45,9 +51,6 @@ done
echo "Enabling debug mode"
ckan config-tool $CKAN_INI -s DEFAULT "debug = true"

# Add ckan.datapusher.api_token to the CKAN config file (updated with corrected value later)
ckan config-tool $CKAN_INI ckan.datapusher.api_token=xxx

# Set up the Secret key used by Beaker and Flask
# This can be overriden using a CKAN___BEAKER__SESSION__SECRET env var
if grep -E "beaker.session.secret ?= ?$" ckan.ini
Expand Down Expand Up @@ -76,9 +79,6 @@ ckan config-tool $SRC_DIR/ckan/test-core.ini \
# Run the prerun script to init CKAN and create the default admin user
python3 prerun.py

echo "Set up ckan.datapusher.api_token in the CKAN config file"
ckan config-tool $CKAN_INI "ckan.datapusher.api_token=$(ckan -c $CKAN_INI user token add ckan_admin datapusher | tail -n 1 | tr -d '\t')"

# Run any startup scripts provided by images extending this one
if [[ -d "/docker-entrypoint.d" ]]
then
Expand Down
2 changes: 1 addition & 1 deletion ckan-2.9/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ENV GIT_URL=https://github.com/ckan/ckan.git
ENV GIT_BRANCH=${CKAN_VERSION}
# Customize these on the .env file if needed
ENV CKAN_SITE_URL=http://localhost:5000
ENV CKAN__PLUGINS image_view text_view recline_view datastore datapusher envvars
ENV CKAN__PLUGINS image_view text_view recline_view datastore envvars

# UWSGI options
ENV UWSGI_HARAKIRI=50
Expand Down

0 comments on commit f77c387

Please sign in to comment.