# Copyright (c) 2020 NVIDIA Corporation.  All rights reserved. 

Bootstrap: docker
FROM: nvcr.io/hpc/pgi-compilers:ce

%environment
    export XDG_RUNTIME_DIR=
    export PATH="$PATH:/opt/pgi/linux86-64/19.10/bin:/usr/local/bin:/opt/anaconda3/bin:/usr/bin"
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib:/opt/pgi/linux86-64-llvm/2019/cuda/10.1/lib64/:/opt/pgi/linux86-64-llvm/19.10/lib" 
    export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib" CPATH="$CPATH:/usr/local/include"
    export PATH=/opt/nvidia/nsight-systems/2020.2.1/bin:/opt/nvidia/nsight-compute/2020.1.1/:$PATH


%post
    build_tmp=$(mktemp -d) && cd ${build_tmp}

    export PATH=/opt/pgi/linux86-64/19.10/bin:$PATH

    apt-get -y update
    apt-get -y dist-upgrade 
    apt-get -y install --no-install-recommends \
	    m4 vim-nox emacs-nox nano zip \
 	    python3 python3-pip python3-setuptools git-core inotify-tools \
	    curl git-lfs \
	    build-essential
    rm -rf /var/lib/apt/cache/* 

    pip3 install --upgrade pip
    pip3 install jupyter netcdf4

    apt-get install --no-install-recommends -y build-essential 

# NVIDIA nsight-systems-2020.1.1 nsight-compute-2020.1.1
    apt-get update -y 
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends apt-transport-https ca-certificates gnupg wget
    echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /" >> /etc/apt/sources.list.d/nsight.list 
    echo "deb https://developer.download.nvidia.com/devtools/repo-deb/x86_64/ /" >> /etc/apt/sources.list.d/nsight.list 
    apt-get update -y 
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends nsight-systems-2020.2.1 nsight-compute-2020.1.1

    apt-get install --no-install-recommends -y build-essential
#


    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh 
    bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/anaconda3 
    rm Miniconda3-latest-Linux-x86_64.sh 
    /opt/anaconda3/bin/conda install -y -q netcdf4

    cd /
    rm -rf ${build_tmp}

%files
    English/ /labs

%runscript
    "$@"

%labels
    AUTHOR mozhgank
