# Stage 1: Build the module
FROM python:3.12

MAINTAINER pi-ux-ce

ENV PYTHONUNBUFFERED 1
ENV ALLOWED_HOSTS 'django-testing.tryton.geeraert.eu'
ENV DEBUG 'True'

WORKDIR /code/


# Install build tools and MaxMind library
RUN apt-get update && \
    apt-get install -y git nano && \
    rm -rf /var/lib/apt/lists/*

# CACHE_BUST forces this layer (and everything after it) to re-run on every
# build, otherwise Docker reuses a cached clone from a previous build and the
# image silently keeps stale code.
ARG CACHE_BUST=1
RUN echo "cache bust: ${CACHE_BUST}" && \
    git clone --depth 1 -b testing https://gitea.tryton.geeraert.eu/pi-ux-ce/Django_kube.git .

RUN pip install --cache-dir=/opt/hostedtoolcache/pip --upgrade pip
RUN pip list --cache-dir=/opt/hostedtoolcache/pip --outdated
RUN pip install --cache-dir=/opt/hostedtoolcache/pip --upgrade wheel
RUN pip install --cache-dir=/opt/hostedtoolcache/pip --upgrade setuptools
RUN pip install --cache-dir=/opt/hostedtoolcache/pip -r requirements.txt

COPY infra/testing/entrypoint.sh /code/entrypoint.sh
RUN chmod +x /code/entrypoint.sh

EXPOSE 8000

ENTRYPOINT ["/code/entrypoint.sh"]

