Skip to content

Commit

Permalink
Merge pull request #35 from unckan/develop
Browse files Browse the repository at this point in the history
Release to main
  • Loading branch information
avdata99 authored Dec 4, 2024
2 parents c6b0214 + 0bee022 commit 359ec37
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 11 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
tags: true
fetch-depth: 0

- name: Read CKAN_UNI_VERSION from docker/ckan/files/env/base.env
id: read_version
Expand All @@ -17,6 +21,11 @@ jobs:
echo "CKAN_UNI_VERSION found $UNI_VERSION"
echo "CKAN_UNI_VERSION=$UNI_VERSION" >> $GITHUB_ENV
- name: Test the tag exists in repo
run: |
echo "CKAN_UNI_VERSION=${{ env.CKAN_UNI_VERSION }}.Check if tag exists in repo"
git rev-parse "${{ env.CKAN_UNI_VERSION }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ docker-compose up
## Imagen pública

La compilación de esta imagen esta [disponible en DockerHub](https://hub.docker.com/r/avdata99/unckan/tags?page=1&ordering=last_updated).

## Crear nuevas extensiones

Se puede crear una nueva extension entrando al contenedor, activando el entorno virtual y corriendo el comando de generación de extensiones.

```bash
make bash
source venv/bin/activate
ckan -c /app/unckan/ckan.ini generate extension -o /app/unckan/src_extensions/
```
2 changes: 1 addition & 1 deletion ckanext-unckan/ckanext/unckan/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__VERSION__ = '0.4.9'
__VERSION__ = '0.4.11'
2 changes: 1 addition & 1 deletion ckanext-unckan/test.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use = config:../../ckan/test-core.ini

# Insert any custom config settings to be used when running your extension's
# tests here. These will override the one defined in CKAN core's test-core.ini
ckan.plugins = unckan pdf_view datapusher_plus api_tracking superset announcements
ckan.plugins = push_errors unckan pdf_view datapusher_plus api_tracking superset announcements

# Logging configuration
[loggers]
Expand Down
3 changes: 3 additions & 0 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ ckan-worker:

bash:
docker compose exec ckan_uni bash

search-index:
docker compose exec ckan_uni ckan search-index rebuild
7 changes: 4 additions & 3 deletions docker/ckan/files/ckan.ini
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ ckan.cors.origin_allow_all = false
ckan.cors.origin_whitelist =

## Plugins Settings ############################################################
ckan.plugins = unckan image_view pdf_view datastore datatables_view datapusher_plus api_tracking superset announcements
ckan.plugins = push_errors unckan image_view pdf_view datastore datatables_view datapusher_plus api_tracking superset announcements
ckan.resource_proxy.timeout = 5

## Front-End Settings ##########################################################
Expand Down Expand Up @@ -253,8 +253,8 @@ ckan.datastore.write_url = <this-will-be-replaced-with-secret>
ckan.datastore.read_url = <this-will-be-replaced-with-secret>

## Scheming settings
scheming.dataset_schemas=ckanext.uni.schemas:uni.yaml
scheming.presets=ckanext.scheming:presets.json
# scheming.dataset_schemas=ckanext.uni.schemas:uni.yaml
# scheming.presets=ckanext.scheming:presets.json

## Datapusher+ #################################################################
ckan.datapusher.formats = csv xls xlsx xlsm xlsb tsv ssv tab application/csv application/vnd.ms-excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ods application/vnd.oasis.opendocument.spreadsheet
Expand All @@ -265,6 +265,7 @@ ckanext.datapusher_plus.qsv_bin=/usr/local/bin/qsvdp
[loggers]
keys = root, ckan, ckanext, werkzeug

# ensure adding our custom handlers
[handlers]
keys = console

Expand Down
10 changes: 9 additions & 1 deletion docker/ckan/files/env/base.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Do not change this file for your local env
# Use local.env to set your local env variables

CKAN_UNI_VERSION=0.4.9
CKAN_UNI_VERSION=0.4.11
CKAN_GIT_URL=https://github.com/ckan/ckan.git
CKAN_GIT_BRANCH=ckan-2.10.5

Expand All @@ -24,6 +24,11 @@ BEAKER_SESSION_VALIDATE_KEY=other-key
DATASTORE_WRITE_URL=postgresql://datastore_write:pass@postgresql_uni/datastore_test
DATASTORE_READ_URL=postgresql://datastore_read:pass@postgresql_uni/datastore_test

# Sysadmin for prod
CKAN_SYSADMIN_USER=ADMIN
CKAN_SYSADMIN_PASS=ADMIN
CKAN_SYSADMIN_MAIL=[email protected]

# Datapusher+
QSV_SNIFF_DELIMITER=True

Expand All @@ -37,3 +42,6 @@ SUPERSER_PROXY_URL=some.proxy.com
SUPERSER_PROXY_PORT=3128
SUPERSER_PROXY_USER=[email protected]
SUPERSER_PROXY_PASS=PASS

# Push-errors extension settings
# SLACK_WEBHOOK_URL=https://hooks.slack.com/services/TP59XXX/B04XXX/rEp2xxxx
23 changes: 22 additions & 1 deletion docker/ckan/files/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ if [ "$IS_DEV_ENV" = "true" ] ; then
else
echo "Sysadmin user already exists"
fi
else
# Get a user from settings
# If CKAN_SYSADMIN_USER is defined, check if the user exists and create it
echo "Checking if prod sysadmin '$CKAN_SYSADMIN_USER' user exists"
OUT=$(ckan user show $CKAN_SYSADMIN_USER)
# if the output says "User: None" then the user does not exist
# We are not going to get an error
if [[ $OUT == *"User: None"* ]]; then
echo "Creating sysadmin user"
ckan user add $CKAN_SYSADMIN_USER password=$CKAN_SYSADMIN_PASS email=$CKAN_SYSADMIN_MAIL
ckan sysadmin add $CKAN_SYSADMIN_USER
else
echo "Sysadmin user already exists"
fi
fi
# Rebuild webassets in can they were patched
ckan asset build
Expand All @@ -71,10 +85,17 @@ service supervisor start

echo "Finished entrypoint.sh"
sleep 3

echo "************************************************"
echo "************************************************"
echo "************************************************"
echo "************************************************"
echo "*********** CKAN is ready to use ***************"
echo "************ at $CKAN_SITE_URL *****************"
echo "************************************************"
echo "************************************************"
echo "************************************************"
echo "************************************************"
ckan push-errors push-message --message "CKAN started successfully" || echo "Push errors failed"

# Any other command to continue running and allow to stop CKAN
tail -f /var/log/supervisor/*.log
8 changes: 6 additions & 2 deletions docker/ckan/files/scripts/install-extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ pip install -e git+https://github.com/NorwegianRefugeeCouncil/ckanext-api-tracki
pip install -r https://raw.githubusercontent.com/NorwegianRefugeeCouncil/ckanext-api-tracking/refs/tags/0.4.1/requirements.txt

echo "Installing Apache Superset extension"
pip install -e git+https://github.com/unckan/[email protected].4#egg=ckanext-superset
pip install -r https://raw.githubusercontent.com/unckan/ckanext-superset/refs/tags/0.1.4/requirements.txt
pip install -e git+https://github.com/unckan/[email protected].7#egg=ckanext-superset
pip install -r https://raw.githubusercontent.com/unckan/ckanext-superset/refs/tags/0.1.7/requirements.txt

echo "Installing Announcements extension"
pip install -e git+https://github.com/okfn/[email protected]#egg=ckanext-announcements
pip install -r https://raw.githubusercontent.com/okfn/ckanext-announcements/0.1.3/requirements.txt

echo "Installing Push Errors extension"
pip install -e git+https://github.com/unckan/[email protected]#egg=ckanext-push-errors
pip install -r https://raw.githubusercontent.com/unckan/ckanext-push-errors/refs/tags/0.1.4/requirements.txt

echo "CKAN extensions installed"
3 changes: 2 additions & 1 deletion docker/ckan/files/scripts/install-os-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ echo "Installing OS dependencies"

# =====================================================
# Install more dependencies
apt install -y gettext-base file git libmagic1 libpq-dev libuchardet-dev postgresql-client supervisor uchardet unzip wget
apt update
apt install -y gettext-base file git libmagic1 libpq-dev libuchardet-dev postgresql-client supervisor uchardet unzip vim wget

# file: for QSV
# git: to pull the CKAN source code from GitHub
Expand Down
10 changes: 10 additions & 0 deletions docker/ckan/files/scripts/setup-ckan-ini-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,15 @@ ckan config-tool ${CKAN_INI} "ckanext.superset.proxy.port = ${SUPERSER_PROXY_POR
ckan config-tool ${CKAN_INI} "ckanext.superset.proxy.user = ${SUPERSER_PROXY_USER}"
ckan config-tool ${CKAN_INI} "ckanext.superset.proxy.pass = ${SUPERSER_PROXY_PASS}"

# push-errors-settings
if [ -z "${SLACK_WEBHOOK_URL}" ]; then
echo "SLACK_WEBHOOK_URL is not set. push-errors will not be configured."
else
echo "Configuring push-errors with SLACK_WEBHOOK_URL"
ckan config-tool ${CKAN_INI} "ckanext.push_errors.url = ${SLACK_WEBHOOK_URL}"
ckan config-tool ${CKAN_INI} "ckanext.push_errors.method = POST"
ckan config-tool ${CKAN_INI} "ckanext.push_errors.headers={}"
ckan config-tool ${CKAN_INI} "ckanext.push_errors.data={\"text\": \"{message}\", \"username\": \"UNCKAN PUSH ERRORS\", \"icon_url\": \"https://github.com/unckan/ckanext-push-errors/raw/main/icons/server-error.png\"}"
fi

echo "Configuration file setup complete"

0 comments on commit 359ec37

Please sign in to comment.