IMAGE ckan_2.9.1-210106
FROM alpine3.12-python3.8_3.8.5-210106

RUN EOF
    # Install runtime dependencies
    apk --no-cache add geos libjpeg-turbo libmagic libpq mailcap zlib

    # Install build dependencies
    apk --no-cache add --virtual .deps build-base git libjpeg-turbo-dev libxml2-dev libxslt-dev postgresql-dev python3-dev zlib-dev

    # Install CKAN
    mkdir -p /srv/ckan
    cd /srv/ckan
    pip install -e 'git+https://github.com/ckan/ckan.git@bb272bfc7167b35cbff8ce48ed815dd4e23597ba#egg=ckan'
    # Hackfix support for python3.7+ and setuptools 46+
    sed -i 's/zope\.interface==4\.3\.2/zope.interface==4.7.2/' /srv/ckan/src/ckan/requirements.txt
    # -I allows dependencies to downgrade six
    pip install -Ir /srv/ckan/src/ckan/requirements.txt
    pip install flask-debugtoolbar

    # Create OS user
    addgroup -S -g 8080 ckan
    adduser -S -u 8080 -h /srv/ckan -s /bin/false -g ckan -G ckan ckan
    chown -R ckan:ckan /srv/ckan

    # Cleanup
    apk --no-cache del .deps
    find /srv/ckan/src -name '.git*' -exec rm -rf {} +
    rm -rf /root/.cache
EOF

COPY ckan.image.d

CMD /bin/s6-svscan /etc/services.d
