FROM python:3.8.10-slim-buster


LABEL authors="Patrick Jentsch <p.jentsch@uni-bielefeld.de>"


ARG DOCKER_GID
ARG UID
ARG GID


ENV FLASK_APP nopaque.py
ENV LANG=C.UTF-8
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1


RUN apt-get update \
 && apt-get install --no-install-recommends --yes \
      build-essential \
      libpq-dev \
 && rm -r /var/lib/apt/lists/*


RUN groupadd --gid ${DOCKER_GID} --system docker \
 && groupadd --gid ${GID} --system nopaque \
 && useradd --create-home --gid ${GID} --groups ${DOCKER_GID} --no-log-init --system --uid ${UID} nopaque
USER nopaque
WORKDIR /home/nopaque

COPY --chown=nopaque:nopaque requirements.txt ./
RUN python -m venv venv \
 && venv/bin/pip install --requirement requirements.txt


COPY --chown=nopaque:nopaque app app
COPY --chown=nopaque:nopaque migrations migrations
COPY --chown=nopaque:nopaque tests tests
COPY --chown=nopaque:nopaque boot.sh config.py nopaque.py ./


# run-time configuration
EXPOSE 5000
ENTRYPOINT ["./boot.sh"]
