Skip to content

Commit

Permalink
update Dockerfile for new ckanext-grouphierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
BWibo committed Feb 28, 2023
1 parent e94940f commit 04ecd53
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 5 deletions.
69 changes: 66 additions & 3 deletions sddi-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,81 @@
# ###############################################################################
# # Build stage
# ###############################################################################
ARG CKAN_VERSION=2.9.7

FROM ghcr.io/keitaroinc/ckan:${CKAN_VERSION} as extbuild

# ckanext-hierarchy ###########################################################
ARG CKAN_EXT_HIERARCHY_VERSION=master
ENV CKAN_EXT_HIERARCHY_VERSION=${CKAN_EXT_HIERARCHY_VERSION}

USER root

RUN set -ex && \
apk update && \
apk add --no-cache --virtual .build-deps \
python3-dev && \
pip install --upgrade pip \
pip install -r https://raw.githubusercontent.com/ckan/ckanext-hierarchy/${CKAN_EXT_HIERARCHY_VERSION}/dev-requirements.txt

RUN set -ex && \
mkdir -p /wheels && \
pip wheel --wheel-dir=/wheels git+https://github.com/davidread/ckanext-hierarchy.git@${CKAN_EXT_HIERARCHY_VERSION}#egg=ckanext-hierarchy && \
pip wheel --wheel-dir=/wheels -r https://raw.githubusercontent.com/ckan/ckanext-hierarchy/${CKAN_EXT_HIERARCHY_VERSION}/requirements.txt && \
curl -o /wheels/ckanext-hierarchy.txt https://raw.githubusercontent.com/ckan/ckanext-hierarchy/${CKAN_EXT_HIERARCHY_VERSION}/requirements.txt && \
ls -lah /wheels

# ckanext-hierarchy ###########################################################
ARG CKAN_EXT_SDDI_VERSION="2.9-support"
ENV CKAN_EXT_SDDI_VERSION=${CKAN_EXT_SDDI_VERSION}

RUN set -ex && \
mkdir -p /wheels && \
pip wheel --wheel-dir=/wheels \
git+https://github.com/tum-gis/ckanext-grouphierarchy-sddi.git@${CKAN_EXT_SDDI_VERSION}#egg=ckanext-grouphierarchy && \
pip wheel --wheel-dir=/wheels -r \
https://raw.githubusercontent.com/tum-gis/ckanext-grouphierarchy-sddi/${CKAN_EXT_SDDI_VERSION}/requirements.txt && \
curl -o /wheels/ckanext-grouphierarchy.txt \
https://raw.githubusercontent.com/tum-gis/ckanext-grouphierarchy-sddi/${CKAN_EXT_SDDI_VERSION}/requirements.txt && \
ls -lah /wheels

###############################################################################
# Runtime stage
###############################################################################
ARG CKAN_VERSION=2.9.7
FROM ghcr.io/keitaroinc/ckan:${CKAN_VERSION} as runtime

ENV CKAN__PLUGINS image_view text_view recline_view datastore datapusher envvars hierarchy_display hierarchy_form display_group

USER root

# Copy python wheels from build stage
ARG CKAN_EXT_SDDI_VERSION="2.9-support"
COPY --from=extbuild /wheels /srv/app/ext_wheels
COPY --chown=ckan:ckan afterinit.d/ ${APP_DIR}/docker-afterinit.d/
ADD https://raw.githubusercontent.com/tum-gis/ckanext-grouphierarchy-sddi/${CKAN_EXT_SDDI_VERSION}/ckanext/grouphierarchy/init_data.json \
/usr/lib/python3.8/site-packages/ckanext/grouphierarchy/init_data.json

# Install runtime dependencies
RUN set -ex && \
pip install --no-cache-dir -U pip && \
pip install --no-cache-dir -U ckanapi

# Copy webassets and init scripts
COPY --chown=ckan:ckan afterinit.d/ ${APP_DIR}/docker-afterinit.d/
COPY --chown=ckan:ckan webassets/ ${DATA_DIR}/webassets/
# ckanext-hierarchy ###########################################################
RUN set -ex && \
pip install --no-index --find-links=/srv/app/ext_wheels ckanext-hierarchy && \
pip install --no-index --find-links=/srv/app/ext_wheels -r /srv/app/ext_wheels/ckanext-hierarchy.txt

# ckanext-hierarchy ###########################################################
RUN set -ex && \
pip install --no-index --find-links=/srv/app/ext_wheels ckanext-grouphierarchy && \
pip install --no-index --find-links=/srv/app/ext_wheels -r /srv/app/ext_wheels/ckanext-grouphierarchy.txt

RUN set -ex && \
ckan config-tool "${APP_DIR}/production.ini" "ckan.plugins = ${CKAN__PLUGINS}" && \
chown -R ckan:ckan /srv/app && \
chown -Rv ckan:ckan /usr/lib/python3.8/site-packages/ckanext/grouphierarchy/init_data.json && \
# Remove wheels
rm -rf /srv/app/ext_wheels

USER ckan
3 changes: 1 addition & 2 deletions sddi-base/afterinit.d/01_create_groups.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env bash

echo "Create SDDI categories, topics, groups, and organizations ..."
envsubst < "$APP_DIR/docker-afterinit.d/groups.jsonl" > "$APP_DIR/docker-afterinit.d/groups_subst.jsonl"
ckanapi batch -c "${APP_DIR}/production.ini" -I "$APP_DIR/docker-afterinit.d/groups_subst.jsonl"
ckan -c "${APP_DIR}/production.ini" grouphierarchy init_data
echo "Create SDDI categories, topics, groups, and organizations ...done!"

0 comments on commit 04ecd53

Please sign in to comment.