Bootstrap: docker
From: ubuntu:24.04

%environment
    export DEBIAN_FRONTEND=noninteractive
    export APP_DIR=/app
    export PATH=/app/conf/exp1/bin:$PATH

%files
    conf /app/conf
    images /app/images
    scripts /app/scripts
    images/scripts/entrypoint.sh /app/scripts
    images/scripts/prepare_ecad_observations.py /app/scripts

%post
    # Install system dependencies
    apt-get update && apt-get install -y --no-install-recommends \
        python3 \
        python3-pip \
        python3-dev \
        python3-venv \
        build-essential \
        wget curl git unzip bash \
        && rm -rf /var/lib/apt/lists/*

    # Run setup script with -f to ensure venv is built fresh
    cd /app/conf
    bash setup.sh

    # Make entrypoint and shell scripts executable
    chmod +x /app/scripts/entrypoint.sh
    find /app -name "*.sh" -type f -exec chmod +x {} +

    # Ensure results directory exists
    mkdir -p /app/results

%runscript
    exec /app/scripts/entrypoint.sh "$@"

