ARG DOCKER_REGISTRY=10.60.129.132:8890
ARG PYTHON_IMAGE=python:3.9.8
FROM ${DOCKER_REGISTRY}/${PYTHON_IMAGE}

# ADD sources.list
RUN echo 'deb http://10.60.129.132/repository/debian-proxy/ bullseye main\ndeb http://10.60.129.132/repository/debian-security-proxy/ bullseye-security main\ndeb http://10.60.129.132/repository/debian-proxy/ bullseye-updates main' > /etc/apt/sources.list

# Install postgres client to run it inside docker-entrypoint
RUN apt-get update -y && \
    apt-get install -y --no-install-recommends postgresql-client gettext tini git jq && \
    rm -rf /var/lib/apt/lists/* && \
    git config --global --add safe.directory /app

# Install poetry to manage dependencies
RUN pip install \
      --no-cache-dir \
      --trusted-host 10.60.129.132 \
      --index-url http://10.60.129.132/repository/PyPI/simple \
      --upgrade pip && \
    pip install \
      --no-cache-dir \
      --trusted-host 10.60.129.132 \
      --index-url http://10.60.129.132/repository/PyPI/simple \
      poetry==1.8.5

WORKDIR /app

# Install packages globally
ENV POETRY_VIRTUALENVS_CREATE=false

# Specifically tells poetry to ignore venvs to avoid conflicting with host environment
ENV POETRY_VIRTUALENVS_IN_PROJECT=false

COPY pyproject.toml poetry.lock ./

# Install requirements inside
RUN poetry install --with dev
