Go to file
Emanuel Marzini e9008166af Merge branch 'ubuntu' into 'main'
Delete 04_patch_smtp_aws_recipient_name.patch

See merge request d4science/ckan-docker!1
2024-08-06 10:38:31 +00:00
.github/workflows removed unused folders 2024-07-23 18:25:29 +02:00
.vscode fixed popular tags in home 2024-07-25 13:07:17 +02:00
ckan changed templates + spatial changes 2024-07-02 17:51:21 +02:00
compose/2.10 added tags and groups pages and routes 2024-07-29 19:23:26 +02:00
images fixed popular tags in home 2024-07-25 13:07:17 +02:00
nginx Initial commit 2024-04-13 08:48:15 +02:00
postgresql Initial commit 2024-04-13 08:48:15 +02:00
src fixed: datasets dont show in datasets 2024-07-02 18:39:58 +02:00
.env changed templates + spatial changes 2024-07-02 17:51:21 +02:00
.env.example changed templates + spatial changes 2024-07-02 17:51:21 +02:00
.gitignore fixed popular tags in home 2024-07-25 13:07:17 +02:00
.hadolint.yaml fixed popular tags in home 2024-07-25 13:07:17 +02:00
CODE_OF_CONDUCT.md fixed popular tags in home 2024-07-25 13:07:17 +02:00
CONTRIBUTING.md fixed popular tags in home 2024-07-25 13:07:17 +02:00
LICENSE fixed popular tags in home 2024-07-25 13:07:17 +02:00
Makefile fixed popular tags in home 2024-07-25 13:07:17 +02:00
NOTICE fixed popular tags in home 2024-07-25 13:07:17 +02:00
README.md Initial commit 2024-04-13 08:48:15 +02:00
ROADMAP.md added tags and groups pages and routes 2024-07-29 19:23:26 +02:00
Readme.md fixed popular tags in home 2024-07-25 13:07:17 +02:00
docker-compose.dev.yml fix error 400 - bad request, changed http to https 2024-05-23 12:02:42 +02:00
docker-compose.yml Initial commit 2024-04-13 08:48:15 +02:00

Readme.md

Dockerized CKAN

build-status License Docker Pulls Chat on Gitter

This repository contains base docker images, examples and docker-compose used to build and run CKAN.

We build and publish docker images built using this repository to Dockerhub:

and Github Container Registry:

Looking to run CKAN on Kubernetes? Check out our CKAN Helm Chart!

Overview

Images are provided in two flavors:

The Docker containers include only the required extensions to start a CKAN instance. The docker images are built using a multi-stage docker approach in order to produce slim production grade docker images with the right libraries and configuration. This multi-stage approach allows us to build python binary wheels in the build stages that later on we install in the main stage.

Directory layout:

  • compose - contains a docker-compose setup allowing users to spin up a CKAN setup easily using docker-compose
  • images - includes docker contexts for building all supported CKAN versions and datapusher
  • examples - includes examples on how to extend the CKAN docker images and how to run them

Running CKAN using docker-compose

To start CKAN using docker-compose, simply change into the compose directory and run

cd compose/2.9
docker-compose build
docker-compose up

Check if CKAN was succesfuly started on http://localhost:5000.

Configuration

In order to configure CKAN within docker-compose we use both build/up time variables loaded via the .env file, and runtime variables loaded via the .ckan-env file.

Variables in the .env file are loaded when running docker-compose build and docker-compose up, while variables in .ckan-env file are used withing the CKAN container at runtime to configure CKAN and CKAN extensions using ckanext-envvars.

Extending CKAN docker images

Check some examples of extending CKAN docker images in the examples directory.

We recommend to use a multi-stage approach to extend the docker images that we provide here. To extend the images the following Dockerfile structure is recommended:

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

# Switch to the root user
USER root

# Install any system packages necessary to build extensions
# Make sure we install python 3.8, cause CKAN is not compatible with 3.9
RUN apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/v3.13/main \
        python3-dev=3.8.10-r0 

# Fetch and build the custom CKAN extensions
RUN pip wheel --wheel-dir=/wheels git+https://github.com/acmecorp/ckanext-acme@0.0.1#egg=ckanext-acme

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

# Add the custom extensions to the plugins list
ENV CKAN__PLUGINS envvars image_view text_view recline_view datastore datapusher acme

# 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-acme && \
    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

Adding init and afterinit scripts

You can add scripts to CKAN custom images and copy them to the docker-entrypoint.d directory. Any *.sh or *.py file in that directory will be executed before the main initialization script (prerun.py) is executed.

You can add scripts to CKAN custom images and copy them to the docker-afterinit.d directory. Any *.sh or *.py file in that directory will be executed after the main initialization script (prerun.py) is executed.

Build

To build a CKAN image run:

docker build --tag ghcr.io/keitaroinc/ckan:2.9.9 images/ckan/2.9

The -tag ghcr.io/keitaroinc/ckan:2.9.9 flag sets the image name to ghcr.io/keitaroinc/ckan:2.9.9 and 'images/ckan/2.9' at the end tells docker build to use the context into the specified directory where the Dockerfile and related contents are.

Upload to DockerHub

It's recommended to upload built images to DockerHub

To upload the image to DockerHub run:

docker push [options] <docker-hub-namespace>/ckan:<image-tag>