feat: 🎉 Add extension dependencies installation scripts

Add scripts to install third-party and local CKAN extensions, and migrate harvester. Updated Dockerfile and environment variables for new extensions, and refactored existing scripts for clarity and consistency.
This commit is contained in:
Maicol Battistini 2024-09-25 11:55:18 +02:00
parent 94af245372
commit 0fa77a9f23
No known key found for this signature in database
8 changed files with 52 additions and 21 deletions

View File

@ -16,18 +16,19 @@ USER root
FROM d4science/ckan:2.11.0-focal
# Add the custom extensions to the plugins list
ENV CKAN__PLUGINS="envvars tracking image_view text_view datatables_view datastore datapusher spatial_metadata spatial_query d4science d4science_theme"
ENV CKAN__PLUGINS="envvars tracking image_view text_view datatables_view datastore datapusher spatial_metadata spatial_query harvest ckan_harvester googleanalytics dcat dcat_rdf_harvester dcat_json_harvester dcat_json_interface structured_data d4science d4science_theme"
# Switch to the root user
USER root
#COPY --from=extbuild /wheels /srv/app/ext_wheels
# Add requirements.txt to the image
COPY requirements.txt /srv/app/requirements.txt
# Add requirements.txt to the image (for extensions)
COPY extensions-requirements.txt /srv/app/extensions-requirements.txt
# Install and enable the custom extensions
RUN pip install -r /srv/app/requirements.txt
RUN pip install -r /srv/app/extensions-requirements.txt
RUN ckan config-tool ${APP_DIR}/production.ini "ckan.plugins = ${CKAN__PLUGINS}" && \
chown -R ckan:ckan /srv/app

View File

@ -0,0 +1,3 @@
#!/bin/bash
ckan config-tool ${APP_DIR}/production.ini "ckanext.spatial.common_map.type=Stadia.StamenTerrain" "ckanext.spatial.common_map.max_zoom=18" "ckanext.spatial.search_backend = solr-spatial-field" "ckan.search.solr_allowed_query_parsers = field" "ckan.harvest.mq.type=redis" "ckan.harvest.mq.hostname=redis" "googleanalytics.id=UA-1010101-1"

View File

@ -1,14 +0,0 @@
#!/bin/bash
if [[ $CKAN__PLUGINS == *"spatial_metadata"* ]]; then
echo "Configuring CKAN spatial ..."
ckan config-tool ${APP_DIR}/production.ini "ckanext.spatial.common_map.type=Stadia.StamenTerrain"
ckan config-tool ${APP_DIR}/production.ini "ckanext.spatial.common_map.max_zoom=18"
# ckan config-tool $CKAN_INI "ckanext.spatial.search_backend = solr-spatial-field"
ckan config-tool ${APP_DIR}/production.ini "ckan.search.solr_allowed_query_parsers = frange"
# forse è da aggiungere un qualche tipo di key per production
else
echo "Not configuring spatial, plugin not enabled."
fi

View File

@ -0,0 +1,24 @@
#!/usr/bin/env bash
EXTENSIONS_DIR=/srv/app/src
# Install any 3rd-party extensions installed
echo "Looking for 3rd-party extensions to install..."
echo "Extension dir ($EXTENSIONS_DIR) contents:"
ls -la $EXTENSIONS_DIR
for i in $EXTENSIONS_DIR/*
do
if [ -d $i ];
then
# if [ -f $i/pip-requirements.txt ];
# then
# pip install -r $i/pip-requirements.txt
# echo "Found requirements file in $i"
# fi
if [ -f $i/requirements.txt ];
then
pip install -r $i/requirements.txt
echo "Found requirements file in $i"
fi
fi
done

View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
# Migrate harvester
ckan --config="$APP_DIR"/production.ini db upgrade -p harvest

View File

@ -1,3 +1,5 @@
#!/usr/bin/env bash
SRC_EXTENSIONS_DIR=/srv/app/src_extensions
# Install any local extensions in the src_extensions volume

View File

@ -0,0 +1,14 @@
# Spatial
-e git+https://github.com/mjanez/ckanext-spatial@v2.1.1#egg=ckanext-spatial
geojson==3.1.0
# Harvester
-e git+https://github.com/ckan/ckanext-harvest.git#egg=ckanext-harvest
# Google Analytics
-e git+https://github.com/ckan/ckanext-googleanalytics.git#egg=ckanext-googleanalytics
# DCAT
-e git+https://github.com/ckan/ckanext-dcat.git#egg=ckanext-dcat
shapely==2.0.6

View File

@ -1,3 +0,0 @@
# Spatial
-e git+https://github.com/mjanez/ckanext-spatial@v2.1.1#egg=ckanext-spatial
-r https://raw.githubusercontent.com/mjanez/ckanext-spatial/master/requirements.txt