2020-12-02 12:49:06 +01:00
|
|
|
##################
|
|
|
|
### Build CKAN ###
|
|
|
|
##################
|
2021-09-16 15:19:37 +02:00
|
|
|
FROM ubuntu:focal-20210827 as ckanbuild
|
2020-12-02 12:49:06 +01: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-focal
|
2021-01-16 01:35:41 +01:00
|
|
|
|
2020-12-02 12:49:06 +01: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
|
2020-12-02 12:49:06 +01:00
|
|
|
|
|
|
|
# Set timezone
|
|
|
|
ENV TZ=UTC
|
|
|
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
|
|
|
|
|
|
|
# Set Locale
|
|
|
|
ENV LC_ALL=en_US.UTF-8
|
|
|
|
|
|
|
|
# Set src dirs
|
|
|
|
ENV SRC_DIR=/srv/app/src
|
|
|
|
ENV PIP_SRC=${SRC_DIR}
|
|
|
|
|
|
|
|
WORKDIR ${SRC_DIR}
|
|
|
|
|
|
|
|
# Set the locale
|
|
|
|
RUN apt-get update
|
2021-01-15 22:24:16 +01:00
|
|
|
RUN apt-get install --no-install-recommends -y locales
|
2020-12-02 12:49:06 +01:00
|
|
|
RUN sed -i "/$LC_ALL/s/^# //g" /etc/locale.gen
|
|
|
|
RUN dpkg-reconfigure --frontend=noninteractive locales
|
|
|
|
RUN update-locale LANG=${LC_ALL}
|
|
|
|
|
|
|
|
# Instal apt-utils
|
2021-01-15 22:24:16 +01:00
|
|
|
RUN apt-get install --no-install-recommends -y \
|
2020-12-02 12:49:06 +01:00
|
|
|
apt-utils
|
|
|
|
|
|
|
|
# Packages to build CKAN requirements and plugins
|
2021-01-15 22:24:16 +01:00
|
|
|
RUN apt-get install --no-install-recommends -y \
|
2020-12-02 12:49:06 +01:00
|
|
|
git \
|
2021-01-15 22:24:16 +01:00
|
|
|
gnupg \
|
2020-12-02 12:49:06 +01:00
|
|
|
curl \
|
2021-01-15 22:24:16 +01:00
|
|
|
ca-certificates \
|
2020-12-02 12:49:06 +01:00
|
|
|
python \
|
|
|
|
linux-headers-generic \
|
|
|
|
gcc-10 \
|
|
|
|
make \
|
|
|
|
g++-10 \
|
|
|
|
autoconf \
|
|
|
|
automake \
|
|
|
|
libtool \
|
|
|
|
patch \
|
|
|
|
libpcre3-dev \
|
|
|
|
libpcre3 \
|
|
|
|
python-dev \
|
|
|
|
libffi-dev \
|
|
|
|
libxml2-dev \
|
|
|
|
libxslt-dev
|
|
|
|
|
|
|
|
# Install version 9.x of postgresql-dev so that CKAN requirements can be built
|
2021-01-15 22:24:16 +01:00
|
|
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
|
|
|
RUN curl -s -o - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
|
2020-12-02 12:49:06 +01:00
|
|
|
RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
|
|
|
|
RUN apt-get update
|
2021-01-15 22:24:16 +01:00
|
|
|
RUN apt-get install --no-install-recommends -y \
|
2020-12-02 12:49:06 +01:00
|
|
|
postgresql-server-dev-9.6
|
|
|
|
|
|
|
|
# Use gcc 10
|
|
|
|
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 --slave /usr/bin/x86_64-linux-gnu-gcc x86_64-linux-gnu-gcc /usr/bin/x86_64-linux-gnu-gcc-10
|
|
|
|
|
|
|
|
#postgresql-server-dev-9.6 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-12-02 12:49:06 +01:00
|
|
|
|
|
|
|
# Fetch and build CKAN and requirements
|
|
|
|
RUN pip install -e git+${GIT_URL}@${GIT_BRANCH}#egg=ckan
|
|
|
|
# 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
|
|
|
|
RUN rm -rf /srv/app/src/ckan/.git
|
|
|
|
RUN pip wheel --wheel-dir=/wheels -r ckan/requirements.txt
|
2022-09-27 15:52:35 +02:00
|
|
|
RUN pip wheel --wheel-dir=/wheels uwsgi==2.0.19.1 gevent==21.12.0 greenlet==1.1.3
|
2020-12-02 12:49:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
###########################
|
|
|
|
### Default-Extensions ####
|
|
|
|
###########################
|
2021-09-16 15:19:37 +02:00
|
|
|
FROM ubuntu:focal-20210827 as extbuild
|
2020-12-02 12:49:06 +01:00
|
|
|
|
|
|
|
# Set src dirs
|
|
|
|
ENV SRC_DIR=/srv/app/src
|
|
|
|
ENV PIP_SRC=${SRC_DIR}
|
|
|
|
|
|
|
|
# List of default extensions
|
|
|
|
ENV DEFAULT_EXTENSIONS envvars
|
|
|
|
|
|
|
|
# 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 apt-get update && \
|
2021-01-15 22:24:16 +01:00
|
|
|
apt-get install --no-install-recommends -y \
|
2020-12-02 12:49:06 +01:00
|
|
|
git \
|
|
|
|
curl \
|
2021-01-15 22:24:16 +01:00
|
|
|
ca-certificates \
|
2020-12-02 12:49:06 +01:00
|
|
|
python \
|
|
|
|
python-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-12-02 12:49:06 +01:00
|
|
|
|
|
|
|
# Fetch and build the default CKAN extensions
|
|
|
|
RUN pip wheel --wheel-dir=/wheels git+${ENVVARS_GIT_URL}@${ENVVARS_GIT_BRANCH}#egg=ckanext-envvars
|
|
|
|
|
|
|
|
############
|
|
|
|
### MAIN ###
|
|
|
|
############
|
2021-09-16 15:19:37 +02:00
|
|
|
FROM ubuntu:focal-20210827
|
2020-12-02 12:49:06 +01: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
|
2020-12-02 12:49:06 +01:00
|
|
|
|
2020-12-02 15:06:37 +01:00
|
|
|
# Set timezone
|
|
|
|
ENV TZ=UTC
|
|
|
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
|
|
|
|
2020-12-02 12:49:06 +01:00
|
|
|
# Set Locale
|
|
|
|
ENV LC_ALL=en_US.UTF-8
|
|
|
|
|
|
|
|
# Set the locale
|
|
|
|
RUN apt-get update && \
|
2021-01-15 22:24:16 +01:00
|
|
|
apt-get install --no-install-recommends -y locales && \
|
2020-12-02 12:49:06 +01:00
|
|
|
sed -i "/$LC_ALL/s/^# //g" /etc/locale.gen && \
|
|
|
|
dpkg-reconfigure --frontend=noninteractive locales && \
|
|
|
|
update-locale LANG=${LC_ALL} && \
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
ENV APP_DIR=/srv/app
|
|
|
|
ENV SRC_DIR=/srv/app/src
|
2021-01-15 22:24:16 +01:00
|
|
|
ENV CKAN_DIR=${SRC_DIR}/ckan
|
2020-12-02 12:49:06 +01:00
|
|
|
ENV DATA_DIR=/srv/app/data
|
|
|
|
ENV PIP_SRC=${SRC_DIR}
|
|
|
|
ENV CKAN_SITE_URL=http://localhost:5000
|
|
|
|
ENV CKAN__PLUGINS envvars image_view text_view recline_view datastore datapusher
|
|
|
|
|
|
|
|
# Install necessary packages to run CKAN
|
2021-01-15 22:24:16 +01:00
|
|
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
2020-12-02 12:49:06 +01:00
|
|
|
RUN apt-get update && \
|
2021-01-15 22:24:16 +01:00
|
|
|
apt-get install --no-install-recommends -y \
|
2020-12-02 12:49:06 +01:00
|
|
|
gettext \
|
|
|
|
curl \
|
2021-01-15 22:24:16 +01:00
|
|
|
ca-certificates \
|
2020-12-02 15:06:37 +01:00
|
|
|
git \
|
2021-01-15 22:24:16 +01:00
|
|
|
gnupg \
|
2020-12-02 12:49:06 +01:00
|
|
|
python \
|
|
|
|
libpython2.7 \
|
|
|
|
libmagic1 \
|
|
|
|
libpcre3 \
|
|
|
|
libxslt1.1 \
|
|
|
|
libxml2 \
|
|
|
|
tzdata \
|
|
|
|
apache2-utils && \
|
|
|
|
rm -rf /var/lib/apt/lists/* && \
|
|
|
|
# Install version 9.x of postgresql-client so that CKAN can run
|
2021-01-15 22:24:16 +01:00
|
|
|
curl -s -o - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
|
2020-12-02 12:49:06 +01:00
|
|
|
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg main" >> /etc/apt/sources.list.d/postgresql.list' && \
|
|
|
|
apt-get update && \
|
2021-01-15 22:24:16 +01:00
|
|
|
apt-get install --no-install-recommends -y \
|
2020-12-02 12:49:06 +01:00
|
|
|
postgresql-client-9.6 && \
|
|
|
|
rm -rf /var/lib/apt/lists/* && \
|
|
|
|
# Create SRC_DIR
|
|
|
|
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-12-02 12:49:06 +01:00
|
|
|
|
|
|
|
# Get artifacts from build stages
|
|
|
|
COPY --from=ckanbuild /wheels /srv/app/wheels
|
|
|
|
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}
|
2020-12-02 12:49:06 +01:00
|
|
|
|
|
|
|
# Additional install steps for build stages artifacts
|
2022-09-27 15:52:35 +02:00
|
|
|
RUN pip install --no-index --find-links=/srv/app/wheels uwsgi==2.0.19.1 gevent==21.12.0
|
2020-12-02 12:49:06 +01:00
|
|
|
# Create a local user and group to run the app
|
|
|
|
RUN groupadd -g 92 ckan && \
|
|
|
|
useradd -rm -d /srv/app -s /bin/bash -g ckan -u 92 ckan
|
|
|
|
|
2021-01-15 22:24:16 +01:00
|
|
|
WORKDIR ${CKAN_DIR}
|
|
|
|
|
2020-12-02 12:49:06 +01:00
|
|
|
# Install CKAN
|
|
|
|
RUN pip install -e /srv/app/src/ckan && \
|
|
|
|
cp who.ini ${APP_DIR} && \
|
|
|
|
pip install --no-index --find-links=/srv/app/wheels -r requirements.txt && \
|
|
|
|
# Install default CKAN extensions
|
|
|
|
pip install --no-index --find-links=/srv/app/ext_wheels ckanext-envvars && \
|
|
|
|
# Create and update CKAN config
|
|
|
|
# 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}" && \
|
|
|
|
# Set the default level for extensions to INFO
|
|
|
|
paster --plugin=ckan config-tool ${APP_DIR}/production.ini -s logger_ckanext -e level=INFO && \
|
|
|
|
# Create the data directory
|
|
|
|
mkdir ${DATA_DIR} && \
|
|
|
|
# Change ownership to app user
|
|
|
|
chown -R ckan:ckan /srv/app
|
|
|
|
|
|
|
|
# Remove wheels
|
|
|
|
RUN rm -rf /srv/app/wheels /srv/app/ext_wheels
|
|
|
|
|
|
|
|
# Copy necessary scripts
|
|
|
|
COPY setup/app ${APP_DIR}
|
|
|
|
|
2021-01-15 22:24:16 +01:00
|
|
|
WORKDIR ${APP_DIR}
|
|
|
|
|
2020-12-16 20:40:10 +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
|
|
|
|
|
2020-12-02 12:49:06 +01:00
|
|
|
# Create entrypoint directory for children image scripts
|
|
|
|
ONBUILD RUN mkdir docker-entrypoint.d
|
|
|
|
|
|
|
|
# Create afterinit directory for children image scripts
|
|
|
|
ONBUILD RUN mkdir docker-afterinit.d
|
|
|
|
|
|
|
|
EXPOSE 5000
|
|
|
|
|
|
|
|
HEALTHCHECK --interval=10s --timeout=5s --retries=5 CMD curl --fail http://localhost:5000/api/3/action/status_show || exit 1
|
|
|
|
|
|
|
|
USER ckan
|
|
|
|
|
|
|
|
CMD ["/srv/app/start_ckan.sh"]
|