Skip to content

Commit

Permalink
SDDI base Docker build CKAN 2.10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ilchebedelovski committed Jan 29, 2024
1 parent 15685c6 commit c0655a4
Showing 1 changed file with 131 additions and 52 deletions.
183 changes: 131 additions & 52 deletions sddi-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,60 @@
###############################################################################
# Build stage
###############################################################################
ARG CKAN_VERSION_BUILD_STAGE=2.9.9-dev
ARG CKAN_VERSION_BUILD_STAGE=2.10.1-dev
ARG CKAN_VERSION_BUILD_SPATIAL=2.9.9-focal
ARG CKAN_VERSION_RUNTIME_STAGE=2.9.9-focal
ARG CKAN_VERSION_RUNTIME_STAGE=2.10.1-focal

FROM ckan/ckan-base:${CKAN_VERSION_BUILD_STAGE} as extbuild

USER root

RUN apk add --no-cache \
# python3 \
# python3-dev \
git \
curl \
postgresql-dev \
linux-headers \
gcc \
make \
g++ \
zlib-dev \
autoconf \
automake \
libtool \
patch \
musl-dev \
pcre-dev \
pcre \
geos \
libffi-dev \
libxml2-dev \
libxslt-dev \
openssl-dev \
rust \
cargo

ARG PYTHON_VERSION=3.9.9

# download and extract python sources
RUN cd /opt \
&& wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz \
&& tar xzf Python-${PYTHON_VERSION}.tgz

# build python and remove left-over sources
RUN cd /opt/Python-${PYTHON_VERSION} \
&& ./configure --prefix=/usr --enable-optimizations --with-ensurepip=install \
&& make install \
&& rm /opt/Python-${PYTHON_VERSION}.tgz /opt/Python-${PYTHON_VERSION} -rf

RUN set -ex && \
pip install --no-cache-dir -U pip && \
rm -rf /var/lib/apt/lists/*

RUN pip install markupsafe==2.0.1 && \
pip install wheel

# ckanext-hierarchy ###########################################################
ARG CKANEXT_HIERARCHY_VERSION="v1.2.0"
ENV CKANEXT_HIERARCHY_VERSION=${CKANEXT_HIERARCHY_VERSION}
Expand Down Expand Up @@ -100,45 +146,38 @@ RUN set -ex && \
pip wheel --wheel-dir=/wheels \
git+${CKANEXT_PASSWORD_POLICY_GITHUB_URL}.git@${CKANEXT_PASSWORD_POLICY_VERSION}#egg=ckanext-password-policy

# ckanext-spatial #############################################################
FROM ghcr.io/keitaroinc/ckan:${CKAN_VERSION_BUILD_SPATIAL} as extbuild-spatial

ARG CKANEXT_SPATIAL_VERSION="c2118b9"
ENV CKANEXT_SPATIAL_VERSION=${CKANEXT_SPATIAL_VERSION}
# ckanext-harvest ###########################################################

USER root
ARG CKANEXT_HARVEST_VERSION="v1.5.6"
ENV CKANEXT_HARVEST_VERSION=${CKANEXT_HARVEST_VERSION}
ENV CKANEXT_HARVEST_GITHUB_URL="https://github.com/ckan/ckanext-harvest.git"

# Install any system packages necessary to build extensions
RUN set -ex && \
apt-get update && \
apt-get install -y --no-install-recommends \
python3-dev python3-pip libxml2-dev libxslt1-dev libgeos-c1v5 python-is-python3 && \
mkdir -p /wheels && \
pip install -U pip
mkdir -p /wheels && \
pip install -r https://raw.githubusercontent.com/ckan/ckanext-harvest/${CKANEXT_HARVEST_VERSION}/dev-requirements.txt

RUN set -ex && \
pip install -r https://raw.githubusercontent.com/MarijaKnezevic/ckanext-spatial/${CKANEXT_SPATIAL_VERSION}/requirements.txt && \
curl -o /wheels/ckanext-spatial.txt \
https://raw.githubusercontent.com/MarijaKnezevic/ckanext-spatial/${CKANEXT_SPATIAL_VERSION}/requirements.txt && \
pip install -r https://raw.githubusercontent.com/MarijaKnezevic/ckanext-spatial/${CKANEXT_SPATIAL_VERSION}/requirements-postgis.txt && \
curl -o /wheels/ckanext-spatial-postgis.txt \
https://raw.githubusercontent.com/MarijaKnezevic/ckanext-spatial/${CKANEXT_SPATIAL_VERSION}/requirements-postgis.txt && \
ls -lah /wheels
pip wheel --wheel-dir=/wheels -r https://raw.githubusercontent.com/ckan/ckanext-harvest/${CKANEXT_HARVEST_VERSION}/requirements.txt && \
pip wheel --wheel-dir=/wheels git+https://github.com/ckan/ckanext-harvest.git@${CKANEXT_HARVEST_VERSION}#egg=ckanext-harvest && \
curl -o /wheels/ckanext-harvest.txt https://raw.githubusercontent.com/ckan/ckanext-harvest/${CKANEXT_HARVEST_VERSION}/requirements.txt && \
ls -lah /wheels

# # ckanext-spatial #############################################################
ENV CKANEXT_SPATIAL_GITHUB_URL="https://github.com/ckan/ckanext-spatial"
ENV CKANEXT_SPATIAL_VERSION="v2.1.1"

RUN set -ex && \
# pip wheel --wheel-dir=/wheels -r \
# https://raw.githubusercontent.com/ckan/ckanext-spatial/v2.1.1/requirements.txt && \
curl -o /wheels/ckanext-spatial-requirements.txt \
https://raw.githubusercontent.com/ckan/ckanext-spatial/v2.1.1/requirements.txt && \
pip wheel --wheel-dir=/wheels \
git+https://github.com/MarijaKnezevic/ckanext-spatial.git@${CKANEXT_SPATIAL_VERSION}#egg=ckanext-spatial
git+${CKANEXT_SPATIAL_GITHUB_URL}.git@${CKANEXT_SPATIAL_VERSION}#egg=ckanext-spatial

###############################################################################
# Runtime stage
###############################################################################
FROM ghcr.io/keitaroinc/ckan:${CKAN_VERSION_RUNTIME_STAGE} as runtime

ENV CKAN__PLUGINS "image_view text_view recline_view webpage_view datastore datapusher \
hierarchy_display hierarchy_form display_group relation \
spatial_metadata spatial_query datesearch repeating composite scheming_datasets \
password_policy \
envvars"
FROM ckan/ckan-base:2.10 as runtime

# Extra env for compatibility with ckan/base Docker images for downstream k8s
ENV CKAN_INI=${APP_DIR}/production.ini
Expand All @@ -147,17 +186,55 @@ ENV TZ="UTC"

USER root

# Install any system packages necessary to build extensions
RUN set -ex && \
apt-get update && \
apt-get install -y --no-install-recommends \
libxml2-dev libxslt1-dev libgeos-c1v5 && \
pip install --no-cache-dir -U pip && \
rm -rf /var/lib/apt/lists/*
RUN apk add --no-cache \
python3 \
python3-dev \
git \
curl \
postgresql-dev \
linux-headers \
gcc \
make \
g++ \
zlib-dev \
autoconf \
automake \
libtool \
patch \
musl-dev \
pcre-dev \
pcre \
geos \
libffi-dev \
libxml2-dev \
libxslt-dev \
openssl-dev \
rust \
cargo \
proj-data

ENV CKAN__PLUGINS "image_view text_view recline_view webpage_view datastore \
harvest ckan_harvester \
hierarchy_display hierarchy_form \
# datapusher Token required \
display_group \
# relation ImportError: cannot import name 'Mapping' from 'collections' \
spatial_metadata spatial_query \
scheming_datasets \
datesearch \
composite \
repeating \
# password_policy No module named 'ckan.lib.repoze_plugins' \
envvars"

RUN pip install markupsafe==2.0.1

# Copy python wheels from build stage
COPY --from=extbuild /wheels ${APP_DIR}/ext_wheels
COPY --from=extbuild-spatial /wheels ${APP_DIR}/ext_wheels

# ckanext-harvest ###########################################################
RUN pip install --no-index --find-links=${APP_DIR}/ext_wheels ckanext-harvest && \
pip install --no-index --find-links=${APP_DIR}/ext_wheels -r ${APP_DIR}/ext_wheels/ckanext-harvest.txt

# ckanext-hierarchy ###########################################################
RUN set -ex && \
Expand All @@ -170,21 +247,20 @@ RUN set -ex && \
pip install --no-index --find-links=${APP_DIR}/ext_wheels ckanext-grouphierarchy

# ckanext-relation ############################################################
RUN set -ex && \
pip install --find-links=${APP_DIR}/ext_wheels -r ${APP_DIR}/ext_wheels/ckanext-relation.txt && \
pip install --no-index --find-links=${APP_DIR}/ext_wheels ckanext-relation
# RUN set -ex && \
# pip install --find-links=${APP_DIR}/ext_wheels -r ${APP_DIR}/ext_wheels/ckanext-relation.txt && \
# pip install --no-index --find-links=${APP_DIR}/ext_wheels ckanext-relation

# ckanext-spatial #############################################################
RUN set -ex && \
pip install -r ${APP_DIR}/ext_wheels/ckanext-spatial.txt && \
pip install -r ${APP_DIR}/ext_wheels/ckanext-spatial-postgis.txt && \
pip install -r ${APP_DIR}/ext_wheels/ckanext-spatial-requirements.txt && \
pip install --no-index --find-links=${APP_DIR}/ext_wheels ckanext-spatial

# ckanext-scheming ############################################################
# # ckanext-scheming ############################################################
RUN set -ex && \
pip install --no-index --find-links=${APP_DIR}/ext_wheels ckanext-scheming

# ckanext-datesearch ##########################################################
# # ckanext-datesearch ##########################################################
RUN set -ex && \
pip install --no-index --find-links=${APP_DIR}/ext_wheels ckanext-datesearch

Expand All @@ -205,20 +281,23 @@ RUN set -ex && \
COPY --chown=ckan:ckan initScripts/ ${APP_DIR}/docker-afterinit.d
COPY --chown=ckan:ckan who.ini ${APP_DIR}/who.ini

RUN set -ex && \
ckan generate config ${APP_DIR}/production.ini

RUN set -ex && \
ckan config-tool "${CKAN_INI}" "ckan.plugins = ${CKAN__PLUGINS}" && \
ckan config-tool "${CKAN_INI}" "ckan.spatial.srid = 4326" && \
ckan config-tool "${CKAN_INI}" "ckanext.spatial.search_backend = solr-bbox" && \
# ckan config-tool "${CKAN_INI}" "ckan.spatial.srid = 4326" && \
# ckan config-tool "${CKAN_INI}" "ckanext.spatial.search_backend = solr-bbox" && \
ckan config-tool "${CKAN_INI}" "scheming.dataset_schemas = ckanext.scheming:ckan_dataset.yaml" && \
ckan config-tool "${CKAN_INI}" "scheming.presets = ckanext.scheming:presets.json ckanext.repeating:presets.json ckanext.composite:presets.json" && \
ckan config-tool "${CKAN_INI}" "scheming.dataset_fallback = false" && \
ckan config-tool "${CKAN_INI}" "licenses_group_url = https://raw.githubusercontent.com/tum-gis/ckanext-grouphierarchy-sddi/main/ckanext/grouphierarchy/licenses_SDDI.json" && \
ckan config-tool "${CKAN_INI}" "ckanext.password_policy.password_length = 12" && \
ckan config-tool "${CKAN_INI}" "ckanext.password_policy.failed_logins = 3" && \
ckan config-tool "${CKAN_INI}" "ckanext.password_policy.user_locked_time = 600" && \
ckan config-tool "${CKAN_INI}" "ckanext.spatial.common_map.type = custom" && \
ckan config-tool "${CKAN_INI}" "ckanext.spatial.common_map.custom.url = https://tile.openstreetmap.de/{z}/{x}/{y}.png" && \
ckan config-tool "${CKAN_INI}" "ckanext.spatial.common_map.attribution = <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors." && \
# ckan config-tool "${CKAN_INI}" "ckanext.password_policy.password_length = 12" && \
# ckan config-tool "${CKAN_INI}" "ckanext.password_policy.failed_logins = 3" && \
# ckan config-tool "${CKAN_INI}" "ckanext.password_policy.user_locked_time = 600" && \
# ckan config-tool "${CKAN_INI}" "ckanext.spatial.common_map.type = custom" && \
# ckan config-tool "${CKAN_INI}" "ckanext.spatial.common_map.custom.url = https://tile.openstreetmap.de/{z}/{x}/{y}.png" && \
# ckan config-tool "${CKAN_INI}" "ckanext.spatial.common_map.attribution = <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors." && \
echo "${TZ}" > /etc/timezone && \
mkdir -p ${CKAN_STORAGE_PATH} && \
chown -R ckan:ckan ${APP_DIR} ${CKAN_STORAGE_PATH} && \
Expand Down

0 comments on commit c0655a4

Please sign in to comment.