2017-10-18 21:21:29 +02:00
|
|
|
##################
|
|
|
|
### Build CKAN ###
|
|
|
|
##################
|
2021-09-16 15:19:37 +02:00
|
|
|
FROM alpine:3.14.2 as ckanbuild
|
2017-10-18 21:21:29 +02:00
|
|
|
|
2021-01-16 01:35:41 +01:00
|
|
|
# Used by Github Actions to tag the image with
|
2021-09-16 15:19:37 +02:00
|
|
|
ENV IMAGE_TAG=2.7.12
|
2021-01-16 01:35:41 +01:00
|
|
|
|
2017-10-18 21:21:29 +02:00
|
|
|
# Set CKAN version to build
|
|
|
|
ENV GIT_URL=https://github.com/ckan/ckan.git
|
2021-09-16 15:19:37 +02:00
|
|
|
ENV GIT_BRANCH=ckan-2.7.12
|
2017-10-18 21:21:29 +02:00
|
|
|
|
|
|
|
# Set src dirs
|
|
|
|
ENV SRC_DIR=/srv/app/src
|
|
|
|
ENV PIP_SRC=${SRC_DIR}
|
|
|
|
|
|
|
|
WORKDIR ${SRC_DIR}
|
|
|
|
|
|
|
|
# Packages to build CKAN requirements and plugins
|
|
|
|
RUN apk add --no-cache \
|
|
|
|
git \
|
|
|
|
curl \
|
2020-06-03 09:53:14 +02:00
|
|
|
python2 \
|
2017-10-18 21:21:29 +02:00
|
|
|
postgresql-dev \
|
|
|
|
linux-headers \
|
|
|
|
gcc \
|
|
|
|
make \
|
|
|
|
g++ \
|
|
|
|
autoconf \
|
|
|
|
automake \
|
|
|
|
libtool \
|
2020-09-20 00:03:36 +02:00
|
|
|
patch \
|
2017-10-18 21:21:29 +02:00
|
|
|
musl-dev \
|
|
|
|
pcre-dev \
|
2019-01-10 23:25:29 +01:00
|
|
|
pcre \
|
2020-06-03 09:53:14 +02:00
|
|
|
python2-dev \
|
|
|
|
libffi-dev \
|
2020-02-17 15:30:52 +01:00
|
|
|
libxml2-dev \
|
|
|
|
libxslt-dev
|
|
|
|
|
2020-09-11 11:28:34 +02:00
|
|
|
# Install version 9.x of postgresql-dev so that CKAN requirements can be built
|
2021-01-15 22:24:16 +01:00
|
|
|
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.6/main \
|
2020-09-11 11:28:34 +02:00
|
|
|
postgresql-dev~=9.6
|
|
|
|
|
2017-10-18 21:21:29 +02:00
|
|
|
# Create the src directory
|
|
|
|
RUN mkdir -p ${SRC_DIR}
|
|
|
|
|
|
|
|
# Install pip
|
2021-03-24 17:40:15 +01:00
|
|
|
RUN curl -o ${SRC_DIR}/get-pip.py https://bootstrap.pypa.io/pip/2.7/get-pip.py && \
|
2021-03-24 17:56:32 +01:00
|
|
|
python ${SRC_DIR}/get-pip.py 'pip==20.3.3'
|
2017-10-18 21:21:29 +02:00
|
|
|
|
|
|
|
# Fetch and build CKAN and requirements
|
|
|
|
RUN pip install -e git+${GIT_URL}@${GIT_BRANCH}#egg=ckan
|
2020-09-20 00:03:36 +02:00
|
|
|
# Copy patches and apply patches script
|
|
|
|
COPY ./patches ${SRC_DIR}/patches
|
|
|
|
COPY ./scripts/apply_ckan_patches.sh ${SRC_DIR}/apply_ckan_patches.sh
|
|
|
|
# Apply patches
|
|
|
|
RUN ${SRC_DIR}/apply_ckan_patches.sh
|
2017-10-18 21:21:29 +02:00
|
|
|
RUN rm -rf /srv/app/src/ckan/.git
|
|
|
|
RUN pip wheel --wheel-dir=/wheels -r ckan/requirements.txt
|
2021-05-19 13:31:52 +02:00
|
|
|
RUN pip wheel --wheel-dir=/wheels uwsgi==2.0.19.1 gevent==21.1.2 greenlet==1.1.0
|
2017-10-18 21:21:29 +02:00
|
|
|
|
2020-06-03 09:53:14 +02:00
|
|
|
|
|
|
|
###########################
|
|
|
|
### Default-Extensions ####
|
|
|
|
###########################
|
2021-09-16 15:19:37 +02:00
|
|
|
FROM alpine:3.14.2 as extbuild
|
2020-06-03 09:53:14 +02:00
|
|
|
|
|
|
|
# Set src dirs
|
|
|
|
ENV SRC_DIR=/srv/app/src
|
|
|
|
ENV PIP_SRC=${SRC_DIR}
|
|
|
|
|
|
|
|
# List of default extensions
|
2020-09-11 12:12:41 +02:00
|
|
|
ENV DEFAULT_EXTENSIONS envvars
|
2020-06-03 09:53:14 +02:00
|
|
|
|
|
|
|
# Locations and tags, please use specific tags or revisions
|
|
|
|
ENV ENVVARS_GIT_URL=https://github.com/okfn/ckanext-envvars
|
|
|
|
ENV ENVVARS_GIT_BRANCH=0.0.1
|
|
|
|
|
|
|
|
RUN apk add --no-cache \
|
|
|
|
git \
|
|
|
|
curl \
|
|
|
|
python2 \
|
|
|
|
python2-dev
|
|
|
|
|
|
|
|
# Create the src directory
|
|
|
|
RUN mkdir -p ${SRC_DIR}
|
|
|
|
|
|
|
|
# Install pip
|
2021-03-24 17:40:15 +01:00
|
|
|
RUN curl -o ${SRC_DIR}/get-pip.py https://bootstrap.pypa.io/pip/2.7/get-pip.py && \
|
2021-03-24 17:56:32 +01:00
|
|
|
python ${SRC_DIR}/get-pip.py 'pip==20.3.3'
|
2020-06-03 09:53:14 +02:00
|
|
|
|
|
|
|
# Fetch and build the default CKAN extensions
|
|
|
|
RUN pip wheel --wheel-dir=/wheels git+${ENVVARS_GIT_URL}@${ENVVARS_GIT_BRANCH}#egg=ckanext-envvars
|
|
|
|
|
2017-10-18 21:21:29 +02:00
|
|
|
############
|
|
|
|
### MAIN ###
|
|
|
|
############
|
2021-09-16 15:19:37 +02:00
|
|
|
FROM alpine:3.14.2
|
2016-08-25 17:40:05 +02:00
|
|
|
|
2021-01-15 22:24:16 +01:00
|
|
|
LABEL maintainer="Keitaro Inc <info@keitaro.com>"
|
|
|
|
LABEL org.opencontainers.image.source https://github.com/keitaroinc/docker-ckan
|
2016-08-25 17:40:05 +02:00
|
|
|
|
|
|
|
ENV APP_DIR=/srv/app
|
2016-10-26 09:28:54 +02:00
|
|
|
ENV SRC_DIR=/srv/app/src
|
2021-01-15 22:24:16 +01:00
|
|
|
ENV CKAN_DIR=${SRC_DIR}/ckan
|
2020-09-11 11:28:34 +02:00
|
|
|
ENV DATA_DIR=/srv/app/data
|
2017-04-06 11:25:21 +02:00
|
|
|
ENV PIP_SRC=${SRC_DIR}
|
2016-08-25 23:04:32 +02:00
|
|
|
ENV CKAN_SITE_URL=http://localhost:5000
|
2020-09-11 12:12:41 +02:00
|
|
|
ENV CKAN__PLUGINS envvars image_view text_view recline_view datastore datapusher
|
2016-08-25 17:40:05 +02:00
|
|
|
|
|
|
|
# Install necessary packages to run CKAN
|
2021-01-15 22:24:16 +01:00
|
|
|
RUN apk add --no-cache \
|
|
|
|
git \
|
2018-08-02 10:34:55 +02:00
|
|
|
bash \
|
2022-01-25 16:14:07 +01:00
|
|
|
git \
|
2016-10-26 09:28:54 +02:00
|
|
|
gettext \
|
2017-10-18 21:21:29 +02:00
|
|
|
curl \
|
2020-06-03 09:53:14 +02:00
|
|
|
python2 \
|
2018-08-02 10:34:55 +02:00
|
|
|
libmagic \
|
2019-01-10 23:25:29 +01:00
|
|
|
pcre \
|
2020-02-17 15:30:52 +01:00
|
|
|
libxslt \
|
|
|
|
libxml2 \
|
|
|
|
tzdata \
|
2017-04-06 11:25:21 +02:00
|
|
|
apache2-utils && \
|
2020-09-11 11:28:34 +02:00
|
|
|
# Install version 9.x of postgresql-client so that CKAN can run
|
2021-01-15 22:24:16 +01:00
|
|
|
apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.6/main \
|
2020-09-11 11:28:34 +02:00
|
|
|
postgresql-client~=9.6 && \
|
2017-04-06 11:25:21 +02:00
|
|
|
# Create SRC_DIR
|
2020-06-03 09:53:14 +02:00
|
|
|
mkdir -p ${SRC_DIR}
|
2017-10-18 21:21:29 +02:00
|
|
|
|
|
|
|
# Install pip
|
2021-03-24 17:40:15 +01:00
|
|
|
RUN curl -o ${SRC_DIR}/get-pip.py https://bootstrap.pypa.io/pip/2.7/get-pip.py && \
|
2021-03-24 17:56:32 +01:00
|
|
|
python ${SRC_DIR}/get-pip.py 'pip==20.3.3'
|
2017-10-18 21:21:29 +02:00
|
|
|
|
|
|
|
# Get artifacts from build stages
|
|
|
|
COPY --from=ckanbuild /wheels /srv/app/wheels
|
2020-06-03 09:53:14 +02:00
|
|
|
COPY --from=extbuild /wheels /srv/app/ext_wheels
|
2021-01-15 22:24:16 +01:00
|
|
|
COPY --from=ckanbuild /srv/app/src/ckan ${CKAN_DIR}
|
2017-10-18 21:21:29 +02:00
|
|
|
|
|
|
|
# Additional install steps for build stages artifacts
|
2021-05-19 13:31:52 +02:00
|
|
|
RUN pip install --no-index --find-links=/srv/app/wheels uwsgi==2.0.19.1 gevent==21.1.2
|
2017-10-18 21:21:29 +02:00
|
|
|
|
|
|
|
# Create a local user and group to run the app
|
|
|
|
RUN addgroup -g 92 -S ckan && \
|
|
|
|
adduser -u 92 -h /srv/app -H -D -S -G ckan ckan
|
|
|
|
|
2021-01-15 22:24:16 +01:00
|
|
|
WORKDIR ${CKAN_DIR}
|
|
|
|
|
2017-04-06 11:25:21 +02:00
|
|
|
# Install CKAN
|
2017-10-18 21:21:29 +02:00
|
|
|
RUN pip install -e /srv/app/src/ckan && \
|
2016-08-25 17:40:05 +02:00
|
|
|
cp who.ini ${APP_DIR} && \
|
2017-10-18 21:21:29 +02:00
|
|
|
pip install --no-index --find-links=/srv/app/wheels -r requirements.txt && \
|
2020-06-03 09:53:14 +02:00
|
|
|
# Install default CKAN extensions
|
2020-09-11 12:12:41 +02:00
|
|
|
pip install --no-index --find-links=/srv/app/ext_wheels ckanext-envvars && \
|
2016-08-25 22:05:30 +02:00
|
|
|
# Create and update CKAN config
|
2020-02-17 15:30:52 +01:00
|
|
|
# Set timezone
|
2020-06-03 09:53:14 +02:00
|
|
|
echo "UTC" > /etc/timezone && \
|
|
|
|
# Generate CKAN config
|
|
|
|
paster --plugin=ckan make-config ckan ${APP_DIR}/production.ini && \
|
|
|
|
paster --plugin=ckan config-tool ${APP_DIR}/production.ini "ckan.plugins = ${CKAN__PLUGINS}" && \
|
2020-10-16 11:59:05 +02:00
|
|
|
# Set the default level for extensions to INFO
|
|
|
|
paster --plugin=ckan config-tool ${APP_DIR}/production.ini -s logger_ckanext -e level=INFO && \
|
2020-09-11 11:28:34 +02:00
|
|
|
# Create the data directory
|
|
|
|
mkdir ${DATA_DIR} && \
|
2017-05-09 18:22:04 +02:00
|
|
|
# Change ownership to app user
|
2018-07-30 14:20:13 +02:00
|
|
|
chown -R ckan:ckan /srv/app
|
|
|
|
|
|
|
|
# Remove wheels
|
2020-06-03 09:53:14 +02:00
|
|
|
RUN rm -rf /srv/app/wheels /srv/app/ext_wheels
|
2016-08-25 17:40:05 +02:00
|
|
|
|
2020-02-17 15:30:52 +01:00
|
|
|
# Copy necessary scripts
|
|
|
|
COPY setup/app ${APP_DIR}
|
|
|
|
|
2021-01-15 22:24:16 +01:00
|
|
|
WORKDIR ${APP_DIR}
|
|
|
|
|
2020-12-16 20:22:35 +01:00
|
|
|
# Copy the alias script for paster to be ckan so it's compatible with 2.9
|
|
|
|
COPY setup/bin/ckan /usr/bin/ckan
|
|
|
|
|
2018-08-07 11:58:04 +02:00
|
|
|
# Create entrypoint directory for children image scripts
|
2019-02-19 11:02:17 +01:00
|
|
|
ONBUILD RUN mkdir docker-entrypoint.d
|
2018-08-07 11:58:04 +02:00
|
|
|
|
2020-09-20 00:45:46 +02:00
|
|
|
# Create afterinit directory for children image scripts
|
|
|
|
ONBUILD RUN mkdir docker-afterinit.d
|
|
|
|
|
2016-08-25 22:13:02 +02:00
|
|
|
EXPOSE 5000
|
2016-08-25 17:40:05 +02:00
|
|
|
|
2017-04-07 09:34:40 +02:00
|
|
|
HEALTHCHECK --interval=10s --timeout=5s --retries=5 CMD curl --fail http://localhost:5000/api/3/action/status_show || exit 1
|
|
|
|
|
2017-05-09 18:22:04 +02:00
|
|
|
USER ckan
|
|
|
|
|
2016-08-25 22:05:30 +02:00
|
|
|
CMD ["/srv/app/start_ckan.sh"]
|