ARG BUILD_ENV=no_copy

FROM python:3.13 AS build_no_copy

ADD ../../requirements.txt .
COPY ../.. /work
RUN rm -r /work/dist | true
RUN python -m pip install --user tox
WORKDIR /work
RUN python -m tox -e build

FROM python:3.13 AS build_copy
COPY dist /work/dist

FROM build_${BUILD_ENV} AS build

FROM python:3.13-slim

RUN --mount=type=cache,target=/var/cache/apt \
    apt-get update && apt-get install -y redis-tools

COPY --from=build /work/dist /dist
RUN for WHEEL in /dist/*.whl; do python -m pip install ${WHEEL}'[lofty]' --extra-index-url https://git.astron.nl/api/v4/groups/36/-/packages/pypi/simple --extra-index-url https://git.astron.nl/api/v4/projects/604/packages/pypi/simple; done
