WSL/SLF GitLab Repository

Dockerfile 3.12 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
ARG EXTERNAL_REG
ARG PYTHON_VERSION

FROM ${EXTERNAL_REG}/python:${PYTHON_VERSION}-slim-bullseye as base

RUN set -ex \
    && apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get install \
       -y --no-install-recommends locales \
    && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
    && rm -rf /var/lib/apt/lists/*

# Set locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
    locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8



FROM base as build

RUN set -ex \
    && apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get install \
    -y --no-install-recommends \
        build-essential \
        gcc \
Sam's avatar
Sam committed
30
        libpq-dev \
31
        git \
Sam's avatar
Sam committed
32
33
34
35
36
        libxml2-dev \
        libxslt-dev \
        libgeos-dev \
        libssl-dev \
        libffi-dev \
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
    && rm -rf /var/lib/apt/lists/*

WORKDIR /opt/repos
ARG CKAN_VERSION
RUN git clone -b "$CKAN_VERSION" --depth 1 \
    https://github.com/EnviDat/ckan-forked.git

WORKDIR /opt/python
# Requirements
RUN pip install --no-cache-dir pipenv==11.9.0 \
    # workarounds for python 3.9 + require setuptools <44
    && sed -i -E "/zope\.interface/s/==.*/==5.2.0/" \
       /opt/repos/ckan-forked/requirements.txt \
    && sed -i -E "/markdown/s/==.*/==3.3.3/" \
       /opt/repos/ckan-forked/requirements.txt \
    && PIPENV_VENV_IN_PROJECT=1 pipenv install \
       -r /opt/repos/ckan-forked/requirements.txt
# CKAN
55
RUN PIPENV_VENV_IN_PROJECT=1 pipenv run \
56
        python -m pip install "/opt/repos/ckan-forked"
57
58
59
60
# Additional plugins
COPY envidat_extensions.* /opt/repos/
RUN chmod +x /opt/repos/envidat_extensions.sh \
    && /opt/repos/envidat_extensions.sh
61
62
63
RUN PIPENV_VENV_IN_PROJECT=1 pipenv run \
        python -m pip install -r "/opt/repos/envidat_extensions.txt" \
    && rm /opt/python/Pipfile /opt/python/Pipfile.lock
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



FROM base as runtime

ARG PYTHON_VERSION
ARG CKAN_VERSION
ARG MAINTAINER
LABEL envidat.com.python-img-tag="${PYTHON_VERSION}" \
      envidat.com.ckan-version="${CKAN_VERSION}" \
      envidat.com.maintainer="${MAINTAINER}"
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PYTHONFAULTHANDLER=1

RUN set -ex \
    && apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get install \
    -y --no-install-recommends \
        libpcre3 \
Sam's avatar
Sam committed
84
        postgresql-client \
85
        libgeos-c1v5 \
Sam's avatar
Sam committed
86
        libmagic1 \
Sam's avatar
Sam committed
87
88
    && rm -rf /var/lib/apt/lists/*

89
90
91
92
93
94
95
WORKDIR /opt/python

COPY --from=build \
    /opt/python/ \
    /opt/python/

ENV PATH="/opt/python/.venv/bin:$PATH"
Sam's avatar
Sam committed
96
97
98
ENV CKAN_HOME /usr/lib/ckan
ENV CKAN_CONFIG /etc/ckan

99
100
COPY config/who.ini $CKAN_CONFIG/
COPY ckan-entrypoint.sh /ckan-entrypoint.sh
Sam's avatar
Sam committed
101

102
103
104
105
106
107
108
109
# Upgrade pip & pre-compile deps to .pyc, add ckan user, permissions
RUN /opt/python/.venv/bin/python -m pip install --no-cache --upgrade pip \
    && python -c "import compileall; compileall.compile_path(maxlevels=10, quiet=1)" \
    && useradd -r -u 900 -m -c "ckan account" -d $CKAN_HOME -s /bin/false ckan \
    && chmod +x /ckan-entrypoint.sh \
    && chown -R ckan:ckan $CKAN_HOME $CKAN_CONFIG

ENTRYPOINT ["/ckan-entrypoint.sh"]
Sam's avatar
Sam committed
110
111
USER ckan
EXPOSE 5000
112
CMD ["ckan", "-c", "/etc/ckan/production.ini", "run", "--host", "0.0.0.0"]