FROM 086679231553.dkr.ecr.us-east-1.amazonaws.com/docker-parent-images:debian13-python313 AS base

WORKDIR /var/app
ENV PYTHONUNBUFFERED=1 \
    VIRTUAL_ENV="/var/app/.venv"
ENV PATH="$VIRTUAL_ENV/bin:$PATH" \
    PYTHONPATH="$PYTHONPATH:/var/app/common:/var/app/src"

RUN python -m venv "$VIRTUAL_ENV" && \
    "$VIRTUAL_ENV"/bin/pip install --no-cache --upgrade pip

COPY --from=common  --chown=worker pyproject.toml config.py ./common/
COPY --from=common  --chown=worker common ./common/common
COPY --chown=worker requirements.txt .

FROM base AS cli

RUN pip install --no-cache ./common -i https://pypi.theorchard.io/pypi && \
    pip install --no-cache -r requirements.txt

COPY src/ ./src

ENTRYPOINT ["python", "-u", "-c", "import asyncio; from src.cli import main; asyncio.run(main())"]

FROM base AS utility

COPY requirements-test.txt ./

RUN pip install --no-cache ./common -i https://pypi.theorchard.io/pypi && \
    pip install --no-cache -r requirements-test.txt

COPY src/ ./src
COPY docker-compose.yaml unit-lint.sh format.sh ./

ENTRYPOINT ["bash"]
