keitaroinc / docker-ckan

CKAN docker images, docker-compose and examples
Apache License 2.0
72 stars 51 forks source link

[BUG] Custom theme installation paths #97

Closed miguelangelch closed 1 year ago

miguelangelch commented 1 year ago

Describe the bug We have developed a custom theme for CKAN: https://github.com/perecanet/ckanext-stomallorca_theme

Based on the Dockerfile extension example, we have installed some extensions included the custom theme. This is the Dockerfile:

###################
### Extensions ####
###################
FROM ghcr.io/keitaroinc/ckan:2.9.8 as extbuild

# Locations and tags, please use specific tags or revisions
ENV MALLORCATHEME_GIT_URL=https://github.com/perecanet/ckanext-stomallorca_theme
ENV MALLORCATHEME_GIT_BRANCH=v0.0.3

ENV SCHEMING_GIT_URL=https://github.com/ckan/ckanext-scheming
ENV SCHEMING_GIT_BRANCH=release-3.0.0

ENV FLUENT_GIT_URL=https://github.com/ckan/ckanext-fluent
ENV FLUENT_GIT_BRANCH=master

# Switch to the root user
USER root

# Install necessary packages to build extensions
RUN apk add --no-cache \
        python3-dev \
        gcc \
        g++ \
        libffi-dev \
        openssl-dev \
        rust \
        cargo

# Scheming CKAN extension
RUN pip wheel --wheel-dir=/wheels git+${SCHEMING_GIT_URL}@${SCHEMING_GIT_BRANCH}#egg=ckanext-scheming
RUN pip wheel --wheel-dir=/wheels -r https://raw.githubusercontent.com/ckan/ckanext-scheming/${SCHEMING_GIT_BRANCH}/test-requirements.txt
RUN curl -o /wheels/scheming.txt https://raw.githubusercontent.com/ckan/ckanext-scheming/${SCHEMING_GIT_BRANCH}/test-requirements.txt

# Fluent CKAN extension
RUN pip wheel --wheel-dir=/wheels git+${FLUENT_GIT_URL}@${FLUENT_GIT_BRANCH}#egg=ckanext-fluent
RUN pip wheel --wheel-dir=/wheels -r https://raw.githubusercontent.com/ckan/ckanext-fluent/${FLUENT_GIT_BRANCH}/dev-requirements.txt
RUN curl -o /wheels/fluent.txt https://raw.githubusercontent.com/ckan/ckanext-fluent/${FLUENT_GIT_BRANCH}/dev-requirements.txt

# stomallorca_theme CKAN extension
RUN pip wheel --wheel-dir=/wheels git+${MALLORCATHEME_GIT_URL}@${MALLORCATHEME_GIT_BRANCH}#egg=ckanext-stomallorca_theme
RUN pip wheel --wheel-dir=/wheels -r https://raw.githubusercontent.com/perecanet/ckanext-stomallorca_theme/${MALLORCATHEME_GIT_BRANCH}/pip-requirements.txt
RUN curl -o /wheels/stomallorca_theme.txt https://raw.githubusercontent.com/perecanet/ckanext-stomallorca_theme/${MALLORCATHEME_GIT_BRANCH}/pip-requirements.txt

USER ckan

############
### MAIN ###
############
FROM ghcr.io/keitaroinc/ckan:2.9.8

LABEL maintainer="Keitaro Inc <info@keitaro.com>"

ENV CKAN__PLUGINS envvars image_view text_view recline_view datastore datapusher scheming_datasets scheming_groups scheming_organizations fluent stomallorca_theme

# Switch to the root user
USER root

COPY --from=extbuild /wheels /srv/app/ext_wheels

# Install and enable the custom extensions
RUN pip install --no-index --find-links=/srv/app/ext_wheels ckanext-scheming && \
    pip install --no-index --find-links=/srv/app/ext_wheels -r /srv/app/ext_wheels/scheming.txt

RUN pip install --no-index --find-links=/srv/app/ext_wheels ckanext-fluent && \
    pip install --no-index --find-links=/srv/app/ext_wheels -r /srv/app/ext_wheels/fluent.txt

RUN pip install --no-index --find-links=/srv/app/ext_wheels ckanext-stomallorca_theme && \
    pip install --no-index --find-links=/srv/app/ext_wheels -r /srv/app/ext_wheels/stomallorca_theme.txt

# Configure plugins
RUN ckan config-tool "${APP_DIR}/production.ini" "ckan.plugins = ${CKAN__PLUGINS}" && \
    chown -R ckan:ckan /srv/app

# Remove wheels
 RUN rm -rf /srv/app/ext_wheels

# Switch to the ckan user
USER ckan

The build works, we are able to generate the Docker image, and run the docker compose, however, checking the CKAN website we see that the style is mixed between the custom theme and the original theme:

image

Why?

Seems that the default templates and public paths are /srv/app/src/ckan/ckan/public and /srv/app/src/ckan/ckan/templates, however, the installation of the custom theme plugin is stored in /usr/lib/python3.8/site-packages/ckanext/stomallorca_theme/ which contains the public and templates folders must use.

We have tried to change the default paths for public and templates but is not able to change it so we have keep it as default:

CKAN__BASE_PUBLIC_FOLDER = public
CKAN__BASE_TEMPLATES_FOLDER = templates

Docker images affected

  1. CKAN 2.9

Logs 2023-04-12 14:09:56,944 INFO [ckan.cli] Using configuration file /srv/app/production.ini 2023-04-12 14:09:56,944 INFO [ckan.config.environment] Loading static files from public 2023-04-12 14:09:57,096 INFO [ckan.config.environment] Loading templates from /srv/app/src/ckan/ckan/templates 2023-04-12 14:09:57,612 INFO [ckan.config.environment] Loading templates from /srv/app/src/ckan/ckan/templates 2023-04-12 14:09:59,867 INFO [ckan.cli] Using configuration file /srv/app/production.ini 2023-04-12 14:09:59,868 INFO [ckan.config.environment] Loading static files from public 2023-04-12 14:09:59,996 INFO [ckan.config.environment] Loading templates from /srv/app/src/ckan/ckan/templates

nadica-rizova commented 1 year ago

@miguelangelch the location of the templates can be changed in the dockerfile RUN ckan config-tool "${APP_DIR}/production.ini" "ckan.template_directory = /usr/lib/python3.8/site-packages/ckanext/stomallorca_theme/templates"

Filip3mac commented 1 year ago

Closing since no response from OP