Skip to content

Commit

Permalink
Makes changes for ckan 2.8.8
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhammadIsmailShahzad committed Jun 8, 2021
1 parent ffa86f5 commit fa42d45
Showing 1 changed file with 87 additions and 26 deletions.
113 changes: 87 additions & 26 deletions rootfs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
##################
### Build CKAN ###
##################
FROM alpine:3.8 as ckanbuild
FROM alpine:3.13.5 as ckanbuild

# Used by Github Actions to tag the image with
ENV IMAGE_TAG=2.8.8

# Set CKAN version to build
ENV GIT_URL=https://github.com/ckan/ckan.git
ENV GIT_BRANCH=ckan-2.8.2
ENV GIT_BRANCH=ckan-2.8.8

# Set src dirs
ENV SRC_DIR=/srv/app/src
Expand All @@ -17,101 +20,159 @@ WORKDIR ${SRC_DIR}
RUN apk add --no-cache \
git \
curl \
python \
python2 \
postgresql-dev \
linux-headers \
gcc \
make \
g++ \
autoconf \
automake \
patch \
libtool \
musl-dev \
pcre-dev \
pcre \
python-dev
python2-dev \
libffi-dev \
libxml2-dev \
libxslt-dev

# Create the src directory
RUN mkdir -p ${SRC_DIR}

# Install pip
RUN curl -o ${SRC_DIR}/get-pip.py https://bootstrap.pypa.io/pip/2.7/get-pip.py && \
python ${SRC_DIR}/get-pip.py pip==20.3.3
python ${SRC_DIR}/get-pip.py 'pip==20.3.3'

# 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
RUN pip wheel --wheel-dir=/wheels uwsgi gevent==1.4.0
RUN pip wheel --wheel-dir=/wheels uwsgi==2.0.19.1 gevent==21.1.2 greenlet==1.1.0


###########################
### Default-Extensions ####
###########################
FROM alpine:3.13.5 as extbuild

# 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 apk add --no-cache \
git \
curl \
python2 \
python2-dev

# Create the src directory
RUN mkdir -p ${SRC_DIR}

# Install pip
RUN curl -o ${SRC_DIR}/get-pip.py https://bootstrap.pypa.io/pip/2.7/get-pip.py && \
python ${SRC_DIR}/get-pip.py 'pip==20.3.3'

# Fetch and build the default CKAN extensions
RUN pip wheel --wheel-dir=/wheels git+${ENVVARS_GIT_URL}@${ENVVARS_GIT_BRANCH}#egg=ckanext-envvars

############
### MAIN ###
############
FROM alpine:3.8

MAINTAINER Keitaro Inc <info@keitaro.com>
FROM alpine:3.13.5

ENV APP_DIR=/srv/app
ENV SRC_DIR=/srv/app/src
ENV CKAN_DIR=${SRC_DIR}/ckan
ENV DATA_DIR=/srv/app/data
ENV PIP_SRC=${SRC_DIR}
ENV CKAN_SITE_URL=http://localhost:5000
ENV CKAN__PLUGINS image_view text_view recline_view datastore datapusher envvars
ENV CKAN__VIEWS__DEFAULT_VIEWS dataexplorer

WORKDIR ${APP_DIR}
ENV CKAN__PLUGINS envvars image_view text_view recline_view datastore datapusher

# Install necessary packages to run CKAN
RUN apk add --no-cache git \
bash \
gettext \
linux-headers \
curl \
postgresql-client \
python \
python2 \
libmagic \
pcre \
libxslt \
libxml2 \
tzdata \
apache2-utils && \
# Create SRC_DIR
mkdir -p ${SRC_DIR}

# Install pip
RUN curl -o ${SRC_DIR}/get-pip.py https://bootstrap.pypa.io/pip/2.7/get-pip.py && \
python ${SRC_DIR}/get-pip.py pip==20.3.3
python ${SRC_DIR}/get-pip.py 'pip==20.3.3'

# Get artifacts from build stages
COPY --from=ckanbuild /wheels /srv/app/wheels
COPY --from=ckanbuild /srv/app/src/ckan /srv/app/src/ckan
COPY --from=extbuild /wheels /srv/app/ext_wheels
COPY --from=ckanbuild /srv/app/src/ckan ${CKAN_DIR}

# Copy necessary scripts
COPY setup/app ${APP_DIR}
# Additional install steps for build stages artifacts
RUN pip install --no-index --find-links=/srv/app/wheels uwsgi gevent
RUN pip install --no-index --find-links=/srv/app/wheels uwsgi==2.0.19.1 gevent==21.1.2

# 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

WORKDIR ${CKAN_DIR}

# Install CKAN
RUN pip install -e /srv/app/src/ckan && \
cd ${SRC_DIR}/ckan && \
cp who.ini ${APP_DIR} && \
pip install --no-index --find-links=/srv/app/wheels -r requirements.txt && \
# Install CKAN envvars to support loading config from environment variables
pip install -e git+https://github.com/okfn/ckanext-envvars.git@0.0.1#egg=ckanext-envvars && \
# Install default CKAN extensions
pip install --no-index --find-links=/srv/app/ext_wheels ckanext-envvars && \
# Create and update CKAN config
# Set timezone
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}" && \
# 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
RUN rm -rf /srv/app/wheels /srv/app/ext_wheels

# Copy necessary scripts
COPY setup/app ${APP_DIR}

WORKDIR ${APP_DIR}

# Copy the alias script for paster to be ckan so it's compatible with 2.9
#COPY setup/bin/ckan /usr/bin/ckan

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


EXPOSE 5000


USER ckan

CMD ["/srv/app/start_ckan.sh"]
CMD ["/srv/app/start_ckan.sh"]

0 comments on commit fa42d45

Please sign in to comment.