Skip to content

Instantly share code, notes, and snippets.

@steveoni
Created August 23, 2023 17:10
Show Gist options
  • Save steveoni/6d006f9dca131461c17628b3aadfa664 to your computer and use it in GitHub Desktop.
Save steveoni/6d006f9dca131461c17628b3aadfa664 to your computer and use it in GitHub Desktop.
Dockerfile.dev
FROM alpine:3.13
# Internals, you probably don't need to change these
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-2.9.4
ENV SRC_EXTENSIONS_DIR=/srv/app/src_extensions
# Customize these on the .env file if needed
ENV CKAN_SITE_URL=http://localhost:5000
ENV CKAN__PLUGINS image_view text_view recline_view datastore datapusher envvars
# UWSGI options
ENV UWSGI_HARAKIRI=50
WORKDIR ${APP_DIR}
# Install necessary packages to run CKAN
RUN apk add --no-cache tzdata \
git \
gettext \
postgresql-client \
python3 \
libxml2 \
libxslt \
musl-dev \
uwsgi \
uwsgi-http \
uwsgi-corerouter \
uwsgi-python \
py3-gevent \
uwsgi-gevent \
libmagic \
curl \
patch \
sudo && \
# 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 && \
#pip wheel --wheel-dir=/wheels uwsgi gevent && \
rm -rf ${SRC_DIR}/get-pip.py
COPY common/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} && \
pip3 install -r requirement-setuptools.txt && \
pip3 install MarkupSafe==2.0.0 && \
pip3 install --no-binary :all: -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
pip3 install --no-cache-dir -e git+https://github.com/datopian/ckanext-auth.git#egg=ckanext-auth && \
# pip3 install -r https://raw.githubusercontent.com/datopian/ckanext-s3filestore/ckan-2.9/requirements.txt && \
# pip3 install -e git+https://github.com/datopian/ckanext-s3filestore.git@ckan-2.9-image-upload-fix#egg=ckanext-s3filestore && \
pip3 install -e git+https://github.com/ckan/ckanext-pages.git#egg=ckanext-pages && \
pip3 install -e git+https://github.com/ckan/ckanext-pdfview.git#egg=ckanext-pdfview && \
# pip3 install -e git+https://github.com/keitaroinc/ckanext-issues@ef694bdfbc223f833a9ba114a8a9ac50cc4520d1#egg=ckanext-issues && \
ckan generate config ${CKAN_INI} && \
ckan config-tool ${CKAN_INI} "ckan.plugins = ${CKAN__PLUGINS}" && \
ckan config-tool ${CKAN_INI} "ckan.site_url = ${CKAN__SITE_URL}" && \
ckan config-tool ${CKAN_INI} -s logger_ckanext -e level=INFO
# ckanext-anonnoaccess
RUN pip3 install -r https://raw.githubusercontent.com/ckan/ckan/${GIT_BRANCH}/dev-requirements.txt
# 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
# Create local storage folder
RUN mkdir -p $CKAN_STORAGE_PATH && \
chown -R ckan:ckan $CKAN_STORAGE_PATH
COPY 2.9/setup/prerun.py ${APP_DIR}
COPY 2.9/setup/supervisor.worker.conf /etc/supervisord.d/worker.conf
COPY 2.9/setup/start_ckan.sh ${APP_DIR}
COPY 2.9/setup/start_ckan_development.sh ${APP_DIR}
ADD https://raw.githubusercontent.com/ckan/ckan/${GIT_BRANCH}/wsgi.py ${APP_DIR}
# Create entrypoint directory for children image scripts
ONBUILD RUN mkdir /docker-entrypoint.d
RUN chown ckan -R /srv/app
ENV CKAN__PLUGINS envvars resource_proxy datopian
RUN ckan config-tool ${CKAN_INI} "ckan.plugins = ${CKAN__PLUGINS}"
EXPOSE 5000
HEALTHCHECK --interval=60s --timeout=5s --retries=5 CMD curl --fail http://localhost:5000/api/3/action/status_show || exit 1
# USER root
CMD ["/srv/app/start_ckan_development.sh"]
# USER root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment