Bootstrap: docker
From: mambaorg/micromamba:1.5
Stage: build

%files
. /opt/mldatafind/

%post
mkdir -p /cvmfs /hdfs /gpfs /ceph /hadoop

# install git for pip installation
apt-get update
apt-get install -y --no-install-recommends git
apt-get clean

# activate micromamba and create environment from lockfile
/bin/bash /root/.bashrc
micromamba create -p /opt/env -f /opt/mldatafind/conda-lock.yml

# install uv so we can install local deps of deps editably
micromamba run -p /opt/env python -m \
    pip install --no-build-isolation uv

cd /opt/mldatafind
micromamba run -p /opt/env \
    uv export --frozen --all-extras -o requirements.txt

# Needs to be pip sync to discover conda env
micromamba run -p /opt/env \
    uv pip install -r requirements.txt

# initialize our shell so that we can execute
# commands in our environment at run time
micromamba shell init --shell=bash --root-prefix=~/micromamba

export PATH=/opt/env/bin:$PATH
echo export PATH=$PATH >> /etc/profile

%environment
    export PATH=/env/bin:$PATH

%runscript
#!/bin/bash
eval "$(micromamba shell hook --shell bash)"
micromamba activate /opt/env
exec "$@"
