2017-10-18 21:21:29 +02:00
|
|
|
##################
|
|
|
|
### Build CKAN ###
|
|
|
|
##################
|
2020-02-17 15:30:52 +01:00
|
|
|
FROM alpine:3.11 as ckanbuild
|
2017-10-18 21:21:29 +02:00
|
|
|
|
|
|
|
# Set CKAN version to build
|
|
|
|
ENV GIT_URL=https://github.com/ckan/ckan.git
|
2020-02-17 15:30:52 +01:00
|
|
|
ENV GIT_BRANCH=master
|
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-02-17 15:30:52 +01:00
|
|
|
python3 \
|
2017-10-18 21:21:29 +02:00
|
|
|
postgresql-dev \
|
|
|
|
linux-headers \
|
|
|
|
gcc \
|
|
|
|
make \
|
|
|
|
g++ \
|
|
|
|
autoconf \
|
|
|
|
automake \
|
|
|
|
libtool \
|
|
|
|
musl-dev \
|
|
|
|
pcre-dev \
|
2019-01-10 23:25:29 +01:00
|
|
|
pcre \
|
2020-02-17 15:30:52 +01:00
|
|
|
python3-dev \
|
|
|
|
libxml2-dev \
|
|
|
|
libxslt-dev
|
|
|
|
|
|
|
|
# Link python to python3
|
|
|
|
RUN ln -s /usr/bin/python3 /usr/bin/python
|
2017-10-18 21:21:29 +02:00
|
|
|
|
|
|
|
# Create the src directory
|
|
|
|
RUN mkdir -p ${SRC_DIR}
|
|
|
|
|
|
|
|
# Install pip
|
|
|
|
RUN curl -o ${SRC_DIR}/get-pip.py https://bootstrap.pypa.io/get-pip.py && \
|
|
|
|
python ${SRC_DIR}/get-pip.py
|
|
|
|
|
|
|
|
# Fetch and build CKAN and requirements
|
|
|
|
RUN pip install -e git+${GIT_URL}@${GIT_BRANCH}#egg=ckan
|
|
|
|
RUN rm -rf /srv/app/src/ckan/.git
|
|
|
|
RUN pip wheel --wheel-dir=/wheels -r ckan/requirements.txt
|
|
|
|
RUN pip wheel --wheel-dir=/wheels uwsgi gevent
|
|
|
|
|
|
|
|
############
|
|
|
|
### MAIN ###
|
|
|
|
############
|
2020-02-17 15:30:52 +01:00
|
|
|
FROM alpine:3.11
|
2016-08-25 17:40:05 +02:00
|
|
|
|
2017-05-09 18:22:04 +02:00
|
|
|
MAINTAINER Keitaro Inc <info@keitaro.com>
|
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
|
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
|
2019-02-09 14:48:56 +01:00
|
|
|
ENV CKAN__PLUGINS envvars image_view text_view recline_view datastore datapusher
|
2016-08-25 17:40:05 +02:00
|
|
|
|
|
|
|
WORKDIR ${APP_DIR}
|
|
|
|
|
|
|
|
# Install necessary packages to run CKAN
|
|
|
|
RUN apk add --no-cache git \
|
2018-08-02 10:34:55 +02:00
|
|
|
bash \
|
2016-10-26 09:28:54 +02:00
|
|
|
gettext \
|
2017-10-18 21:21:29 +02:00
|
|
|
curl \
|
2016-10-26 09:28:54 +02:00
|
|
|
postgresql-client \
|
2020-02-17 15:30:52 +01:00
|
|
|
python3 \
|
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 && \
|
|
|
|
# Create SRC_DIR
|
2020-02-17 15:30:52 +01:00
|
|
|
mkdir -p ${SRC_DIR} && \
|
|
|
|
# Link python to python3
|
|
|
|
ln -s /usr/bin/python3 /usr/bin/python
|
2017-10-18 21:21:29 +02:00
|
|
|
|
|
|
|
# Install pip
|
|
|
|
RUN curl -o ${SRC_DIR}/get-pip.py https://bootstrap.pypa.io/get-pip.py && \
|
|
|
|
python ${SRC_DIR}/get-pip.py
|
|
|
|
|
|
|
|
# Get artifacts from build stages
|
|
|
|
COPY --from=ckanbuild /wheels /srv/app/wheels
|
|
|
|
COPY --from=ckanbuild /srv/app/src/ckan /srv/app/src/ckan
|
|
|
|
|
|
|
|
# Additional install steps for build stages artifacts
|
|
|
|
RUN pip install --no-index --find-links=/srv/app/wheels uwsgi gevent
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
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-10-26 09:28:54 +02:00
|
|
|
cd ${SRC_DIR}/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 && \
|
2017-04-06 11:25:21 +02:00
|
|
|
# Install CKAN envvars to support loading config from environment variables
|
2017-05-09 18:22:04 +02:00
|
|
|
pip install -e git+https://github.com/okfn/ckanext-envvars.git@0.0.1#egg=ckanext-envvars && \
|
2016-08-25 22:05:30 +02:00
|
|
|
# Create and update CKAN config
|
2020-02-17 15:30:52 +01:00
|
|
|
# ckan generate config requires cookiecutter which is in the dev-requirements, temp workaround
|
|
|
|
pip install cookiecutter==1.6.0 && \
|
|
|
|
# Set timezone
|
|
|
|
echo "Europe/Stockholm" > /etc/timezone && \
|
|
|
|
ckan generate config ${APP_DIR}/production.ini && \
|
|
|
|
# Not working atm since ckan config tool tries to load config before executing config-tool, workaround
|
|
|
|
#ckan -c ${APP_DIR}/production.ini config-tool "ckan.plugins = ${CKAN__PLUGINS}" && \
|
|
|
|
sed -i "/ckan.plugins = stats/c ckan.plugins = ${CKAN__PLUGINS}" ${APP_DIR}/production.ini && \
|
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
|
|
|
|
RUN rm -rf /srv/app/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}
|
|
|
|
|
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
|
|
|
|
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"]
|