2020-09-11 11:28:34 +02:00
|
|
|
#############
|
|
|
|
### Build ###
|
|
|
|
#############
|
2021-09-16 15:19:37 +02:00
|
|
|
FROM alpine:3.14.2 as build
|
2020-09-11 11:28:34 +02:00
|
|
|
|
2021-01-16 01:35:41 +01:00
|
|
|
# Used by Github Actions to tag the image with
|
|
|
|
ENV IMAGE_TAG=0.0.17
|
|
|
|
|
2020-09-11 11:28:34 +02:00
|
|
|
# Set datapusher version to build
|
|
|
|
ENV GIT_URL https://github.com/keitaroinc/datapusher.git
|
2020-09-20 00:03:36 +02:00
|
|
|
ENV GIT_BRANCH master
|
2020-09-11 11:28:34 +02:00
|
|
|
ENV REQUIREMENTS_URL https://raw.githubusercontent.com/keitaroinc/datapusher/${GIT_BRANCH}/requirements.txt
|
|
|
|
|
|
|
|
# Set src dirs
|
|
|
|
ENV SRC_DIR=/srv/app/src
|
|
|
|
ENV PIP_SRC=${SRC_DIR}
|
|
|
|
|
|
|
|
WORKDIR ${SRC_DIR}
|
|
|
|
|
|
|
|
# Packages to build datapusher
|
|
|
|
RUN apk add --no-cache \
|
|
|
|
python3 \
|
|
|
|
curl \
|
|
|
|
gcc \
|
|
|
|
make \
|
|
|
|
g++ \
|
|
|
|
autoconf \
|
|
|
|
automake \
|
|
|
|
libtool \
|
|
|
|
git \
|
|
|
|
musl-dev \
|
|
|
|
python3-dev \
|
|
|
|
libffi-dev \
|
|
|
|
openssl-dev \
|
|
|
|
libxml2-dev \
|
2021-02-18 14:36:39 +01:00
|
|
|
libxslt-dev \
|
|
|
|
rust \
|
|
|
|
cargo
|
2020-09-11 11:28:34 +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 && \
|
|
|
|
python3 ${SRC_DIR}/get-pip.py
|
|
|
|
|
|
|
|
# Fetch and build datapusher and requirements
|
|
|
|
RUN pip wheel --wheel-dir=/wheels git+${GIT_URL}@${GIT_BRANCH}#egg=datapusher
|
|
|
|
RUN pip wheel --wheel-dir=/wheels -r ${REQUIREMENTS_URL}
|
|
|
|
RUN curl -o /wheels/requirements.txt ${REQUIREMENTS_URL}
|
|
|
|
|
|
|
|
# Get uwsgi and gevent from pip
|
2020-09-25 08:05:26 +02:00
|
|
|
RUN pip wheel --wheel-dir=/wheels uwsgi==2.0.19.1 gevent==20.6.2 greenlet==0.4.16
|
2020-09-11 11:28:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
############
|
|
|
|
### MAIN ###
|
|
|
|
############
|
2021-09-16 15:19:37 +02:00
|
|
|
FROM alpine:3.14.2
|
2020-09-11 11:28:34 +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
|
2020-09-11 11:28:34 +02:00
|
|
|
|
|
|
|
ENV APP_DIR=/srv/app
|
|
|
|
ENV JOB_CONFIG ${APP_DIR}/datapusher_settings.py
|
|
|
|
|
|
|
|
WORKDIR ${APP_DIR}
|
|
|
|
|
|
|
|
RUN apk add --no-cache \
|
|
|
|
python3 \
|
|
|
|
curl \
|
|
|
|
libmagic \
|
|
|
|
libxslt
|
|
|
|
|
|
|
|
# Install pip
|
2021-01-15 22:24:16 +01:00
|
|
|
RUN curl -o /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py && \
|
|
|
|
python3 /tmp/get-pip.py
|
2020-09-11 11:28:34 +02:00
|
|
|
|
|
|
|
# Get artifacts from build stages
|
|
|
|
COPY --from=build /wheels /srv/app/wheels
|
|
|
|
|
|
|
|
# Install uwsgi and gevent
|
2021-01-15 22:24:16 +01:00
|
|
|
RUN pip install --no-index --find-links=/srv/app/wheels uwsgi==2.0.19.1 gevent==20.6.2
|
2020-09-11 11:28:34 +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
|
|
|
|
|
|
|
|
# Install datapusher
|
|
|
|
RUN pip install --no-index --find-links=/srv/app/wheels datapusher && \
|
|
|
|
pip install --no-index --find-links=/srv/app/wheels -r /srv/app/wheels/requirements.txt && \
|
|
|
|
# Set timezone
|
|
|
|
echo "UTC" > /etc/timezone && \
|
|
|
|
# Change ownership to app user
|
|
|
|
chown -R ckan:ckan /srv/app
|
|
|
|
|
|
|
|
# Remove wheels
|
|
|
|
RUN rm -rf /srv/app/wheels
|
|
|
|
|
|
|
|
COPY setup ${APP_DIR}
|
|
|
|
|
|
|
|
EXPOSE 8000
|
|
|
|
|
|
|
|
USER ckan
|
|
|
|
|
|
|
|
CMD ["uwsgi", "--socket=/tmp/uwsgi.sock", "--uid=92", "--gid=92", "--http=:8000", "--master", "--enable-threads", "--gevent=2000", "-p 2", "-L", "--wsgi-file=wsgi.py"]
|