Skip to content

Commit

Permalink
Merge pull request #44 from ckan/build-master-brancb
Browse files Browse the repository at this point in the history
Build images for CKAN master branch
  • Loading branch information
kowh-ai authored Feb 22, 2024
2 parents 2871058 + efd9b37 commit 1a8015e
Show file tree
Hide file tree
Showing 13 changed files with 660 additions and 7 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/publish-docker-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build and publish the master docker-ckan image
on:
schedule:
- cron: '15 5 * * *'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build ckan-base master
uses: docker/build-push-action@v5
with:
context: ckan-master/base
file: ckan-master/base/Dockerfile
push: true
tags: |
ckan/ckan-base:master
- name: Build ckan-dev master
uses: docker/build-push-action@v5
with:
context: ckan-master/dev
file: ckan-master/dev/Dockerfile
push: true
tags: |
ckan/ckan-dev:master
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ The following CKAN versions are available in base or dev forms. They are disting

| CKAN Version | Type | Docker tag | Notes |
| --- | --- | --- | --- |
| 2.9.10 | base image | `ckan/ckan-base:2.9.10` | |
| 2.9.10 | dev image | `ckan/ckan-dev:2.9.10` | |
| 2.10.3 | base image | `ckan/ckan-base:2.10.3` | |
| 2.10.3 | dev image | `ckan/ckan-dev:2.10.3` | |
| 2.9.x | base image | `ckan/ckan-base:2.9`, `ckan/ckan-base:2.9.9` | |
| 2.9.x | dev image | `ckan/ckan-dev:2.9`, `ckan/ckan-dev:2.9.9` | |
| 2.10.x | base image | `ckan/ckan-base:2.10`,`ckan/ckan-base:2.10.3` | |
| 2.10.x | dev image | `ckan/ckan-dev:2.10`, `ckan/ckan-dev:2.10.3` | |
| master | base image | `ckan/ckan-base:master` | Built daily, do not use in production |
| master | dev image | `ckan/ckan-dev:master` | Built daily, do not use in production |


Older CKAN versions might be available as [image tags](https://hub.docker.com/r/ckan/ckan-base/tags) but note that these are not supported as per [CKAN's release policy](https://docs.ckan.org/en/latest/maintaining/releases.html#supported-versions).

Expand All @@ -23,19 +26,23 @@ Older CKAN versions might be available as [image tags](https://hub.docker.com/r/
The images can be built locally and tagged appropriately so they can then be pushed into the CKAN DockerHub repo
assuming you have the correct permission to do so

For CKAN 2.9.* base images, go to the `ckan-2.9/base` directory and use the Makefile included:
For CKAN 2.9 base images, go to the `ckan-2.9/base` directory and use the Makefile included:


cd ckan-2.9/base
make build (can then use locally)
make push (if you have enough credentials)

For CKAN 2.9.* dev images, go to the `ckan-2.9/dev` directory and use the Makefile included:

For CKAN 2.9 dev images, go to the `ckan-2.9/dev` directory and use the Makefile included:


cd ckan-2.9/dev
make build (can then use locally)
make push (if you have enough credentials)

Same with the CKAN 2.10.* base and dev images

Same with the CKAN 2.10 base and dev images

cd ckan-2.10/base
make build
Expand Down
111 changes: 111 additions & 0 deletions ckan-master/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
FROM alpine:3.17
ARG CKAN_VERSION=master

# Internals, you probably don't need to change these
ENV TZ=UTC
ENV APP_DIR=/srv/app
ENV SRC_DIR=/srv/app/src
ENV CKAN_INI=${APP_DIR}/ckan.ini
ENV PIP_SRC=${SRC_DIR}
ENV CKAN_STORAGE_PATH=/var/lib/ckan
ENV GIT_URL=https://github.com/ckan/ckan.git
# CKAN version to build
ENV GIT_BRANCH=${CKAN_VERSION}
# Customize these on the .env file if needed
ENV CKAN_SITE_URL=http://localhost:5000
ENV CKAN__PLUGINS image_view text_view datatables_view datastore envvars

# UWSGI options
ENV UWSGI_HARAKIRI=50

WORKDIR ${APP_DIR}

# Set up timezone
RUN apk add --no-cache tzdata
RUN echo ${TZ} > /etc/timezone
# Make sure both files are not exactly the same
RUN if ! [ /usr/share/zoneinfo/${TZ} -ef /etc/localtime ]; then \
cp /usr/share/zoneinfo/${TZ} /etc/localtime ;\
fi ;

# Install necessary packages to run CKAN
RUN apk add --no-cache git \
gettext \
postgresql-client \
python3 \
libxml2 \
libxslt \
musl-dev \
uwsgi \
uwsgi-http \
uwsgi-corerouter \
uwsgi-python \
py3-gevent \
uwsgi-gevent \
libmagic \
curl \
patch \
bash && \
# Packages to build CKAN requirements and plugins
apk add --no-cache --virtual .build-deps \
postgresql-dev \
gcc \
make \
g++ \
autoconf \
automake \
libtool \
python3-dev \
libxml2-dev \
libxslt-dev \
linux-headers \
openssl-dev \
libffi-dev \
cargo && \
# Create SRC_DIR
mkdir -p ${SRC_DIR} && \
# Install pip, supervisord and uwsgi
curl -o ${SRC_DIR}/get-pip.py https://bootstrap.pypa.io/get-pip.py && \
python3 ${SRC_DIR}/get-pip.py && \
pip3 install supervisor && \
mkdir /etc/supervisord.d && \
rm -rf ${SRC_DIR}/get-pip.py

COPY setup/supervisord.conf /etc

# Install CKAN
RUN pip3 install -e git+${GIT_URL}@${GIT_BRANCH}#egg=ckan && \
cd ${SRC_DIR}/ckan && \
cp who.ini ${APP_DIR} && \
# Workaround, can be removed when this is merged
# https://github.com/ckan/ckan/pull/7936
sed -i 's/backports-zoneinfo==0.2.1//' requirements.txt && \
pip3 install --no-binary markdown -r requirements.txt && \
# Install CKAN envvars to support loading config from environment variables
pip3 install -e git+https://github.com/okfn/ckanext-envvars.git#egg=ckanext-envvars && \
# Create and update CKAN config
ckan generate config ${CKAN_INI} && \
ckan config-tool ${CKAN_INI} "SECRET_KEY = " && \
ckan config-tool ${CKAN_INI} "ckan.plugins = ${CKAN__PLUGINS}"

# Create a local user and group to run the app
RUN addgroup -g 92 -S ckan && \
adduser -u 92 -h /home/ckan -s /bin/bash -D -G ckan ckan

# Create local storage folder
RUN mkdir -p ${CKAN_STORAGE_PATH} && \
chown -R ckan:ckan ${CKAN_STORAGE_PATH}

COPY setup/prerun.py ${APP_DIR}
COPY setup/start_ckan.sh ${APP_DIR}
ADD https://raw.githubusercontent.com/ckan/ckan/${GIT_BRANCH}/wsgi.py ${APP_DIR}
RUN chmod 644 ${APP_DIR}/wsgi.py

# Create entrypoint directory for children image scripts
ONBUILD RUN mkdir /docker-entrypoint.d

EXPOSE 5000

HEALTHCHECK --interval=60s --timeout=5s --retries=5 CMD curl --fail http://localhost:5000/api/3/action/status_show || exit CMD ["/srv/app/start_ckan.sh"]

CMD ["/srv/app/start_ckan.sh"]
14 changes: 14 additions & 0 deletions ckan-master/base/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.PHONY: all help build build-all push
SHELL := /bin/bash
CKAN_VERSION=master
TAG_NAME="ckan/ckan-base:$(CKAN_VERSION)"

all: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

build: ## Build a CKAN 2.x.x image , `make build`
docker build --build-arg="CKAN_VERSION=$(CKAN_VERSION)" -t $(TAG_NAME) .

push: ## Push a CKAN 2.x.x image to the DockerHub registry, `make push`
docker push $(TAG_NAME)
Loading

0 comments on commit 1a8015e

Please sign in to comment.