FROM mambaorg/micromamba:2.5.0 AS builder

COPY --chown=$MAMBA_USER:$MAMBA_USER ./docker /immunopipe/docker

ARG MAMBA_DOCKERFILE_ACTIVATE=1

# Allow uv to install into the conda (system) Python without a virtual environment
ENV UV_SYSTEM_PYTHON=true

RUN micromamba env update -n base -f /immunopipe/docker/environment_base.yml && \
    micromamba clean --all --yes && \
    python /immunopipe/docker/cleanup.py

# Fresh stage: copy only the trimmed /opt/conda into a clean micromamba image.
# This avoids carrying any build-time layer bloat from the installer stage.
FROM mambaorg/micromamba:2.5.0

COPY --from=builder /opt/conda /opt/conda

# Prevent Python from writing .pyc files at runtime
ENV PYTHONDONTWRITEBYTECODE=true

ENTRYPOINT [ "/usr/local/bin/_entrypoint.sh" ]
