FROM mambaorg/micromamba:2.5.0 AS builder

COPY --chown=$MAMBA_USER:$MAMBA_USER . /biopipen

WORKDIR /biopipen

ARG MAMBA_DOCKERFILE_ACTIVATE=1
# Install dependencies
# nodejs is for report building (pipen-report)
# procps-ng is for `free` command for memory info by pipen-runinfo
RUN micromamba install -y -n base python=3.11 nodejs=22 git uv procps-ng && \
    micromamba clean --all --yes && \
    uv pip install --system -e .[runinfo,log2file] && \
    pipen report update && \
    python /biopipen/docker/cleanup.py

FROM mambaorg/micromamba:2.5.0

COPY --chown=$MAMBA_USER:$MAMBA_USER --from=builder /biopipen /biopipen
COPY --chown=$MAMBA_USER:$MAMBA_USER --from=builder /opt/conda /opt/conda

WORKDIR /workdir
# to test it:
# docker run -it --rm biopipen/base:latest pipen run scrna --help
ENTRYPOINT [ "/usr/local/bin/_entrypoint.sh" ]
