FROM alpine:3.6

ENV APPS_DIR /opt/apps
ENV DB_DIR $APPS_DIR/db
ENV STATIC_ROOT $APPS_DIR/static

COPY requirements.txt $APPS_DIR/

WORKDIR $APPS_DIR

# uWSGI requires linux-headers
# django-split-settings needs ca-certificates as they changed on PyPi
RUN set -ex \
  && buildDeps=' \
    build-base \
    ca-certificates \
    linux-headers \
    python3-dev \
  ' \
  && apk --no-cache --update add \
    gettext \
    mailcap \
    python3 \
    $buildDeps \
  && pip3 install --no-cache-dir --upgrade pip \
  && pip3 install --no-cache-dir --upgrade -r requirements.txt \
  && apk del $buildDeps \
  && rm -rf /var/cache/apk/*

COPY ./collection .

VOLUME $DB_DIR

COPY ./docker-entrypoint.sh .
COPY ./uwsgi.ini .
ENTRYPOINT ["./docker-entrypoint.sh"]

EXPOSE 8000
CMD ["prod"]
