Bootstrap: docker
# Download base image from cern repo on docker hub
From: cern/cc7-base:latest

%files
    /home/sophie/.ssh/rsa_xps7590_1 

%post
    SHHKEY='/home/sophie/.ssh/rsa_xps7590_1'
    HKHYPERKTAG='v1r3.5'
    HKCONFIGTAG='v1r4.4'

    yum install -y \
    wget \
    tar \
    cmake \
    cmake3 \
    make \
    gcc-c++ \
    gcc \
    gcc-gfortran \
    make \
    which \
    emacs \
    vim \
    binutils \
    git \
    libX11-devel \
    libXpm-devel \
    libXft-devel \
    libXext-devel \
    libzstd-devel \
    mesa-libGL-devel \
    mesa-libGLU-devel \
    libXmu-devel \
    libXi-devel \
    expat-devel \
    zlib-devel \
    file \
    bzip2-devel \
    binutils \
    doxygen \
    python-devel \
    python-pip \
    openssl-devel \
    libffi-devel \
    && yum clean all \
    && rm -rf /var/cache/yum
    echo ''
    echo 'Finished installing dependencies'
    echo ''
    echo ''

    echo 'About to clone hyperk software'
    echo ''
    mkdir -p /opt/HyperK
    cd /opt/HyperK/
    echo 'PWD = ' $PWD
    echo ''
    eval `ssh-agent -s`
    ssh-add ${SHHKEY}
    git clone git@github.com:/hyperk/hk-hyperk.git
    cd hk-hyperk
    echo 'PWD = ' $PWD
    git checkout tags/${HKHYPERKTAG}
    git status
    echo './get_release.sh -p hk-config'
    ./get_release.sh -p hk-config
    cd ../hk-config
    echo 'PWD = ' $PWD
    git checkout tags/${HKCONFIGTAG} 
    git status
    echo ''
    cat hk-prod.cfg
    echo '' 
    cd ../hk-hyperk/
    echo 'PWD = ' $PWD
    export PKG_CONFIG=/opt/HyperK/hk-config/hk-prod.cfg 
    echo 'PKG_CONFIG = ' $PKG_CONFIG 
    export PKG_LIST=/opt/HyperK/hk-config/hk-packages.cfg
    echo 'PKG_LIST = ' $PKG_LIST
    echo '\n Get release '
    ./get_release.sh -t
    echo ''
    echo ''
    echo ''

    echo 'About to install hyperk software'
    echo ''
    g++ --version
    cmake --version
    python --version
    echo ''
    cd /opt/HyperK/hk-hyperk
    sed -i 's/cmake -DGEANT4_INSTALL_DATA=ON/cmake -DGEANT4_INSTALL_DATA_TIMEOUT=20000  -DGEANT4_INSTALL_DATA=ON /g'  modules/packages/build_Geant4.sh 
    cat ./modules/packages/build_Geant4.sh
    echo ''

    cd /opt/
    wget https://www.python.org/ftp/python/3.7.11/Python-3.7.11.tgz
    tar xzf Python-3.7.11.tgz
    cd Python-3.7.11
    ./configure --enable-optimizations
    make altinstall
    cd /opt/HyperK/sntools
    pip3.7 install -r requirements.txt

    echo ''
    cd /opt/HyperK/hk-hyperk
    date
    ./build.sh -p ALL build
    date
    echo 'Build done'
    echo ''
    echo 'Container image complete'
    echo 'Enjoy.'

