Bootstrap: docker
From: ubuntu:16.04

%files
    #OpenFOAM-2.4.0.tgz /opt

%environment
    export TERM=linux
    export DEBIAN_FRONTEND=noninteractive
    export FOAM_INST_DIR=/opt
    . /opt/OpenFOAM-2.4.0/etc/bashrc

%post -c /bin/bash
    rm /etc/localtime
    echo America/Buenos_Aires > /etc/localtime
    echo "Installing required packages..."
    apt-get update && apt-get install -y && apt-get install -y build-essential cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot libreadline-dev libncurses-dev libxt-dev libopenmpi-dev openmpi-bin libboost-system-dev libboost-thread-dev libgmp-dev libmpfr-dev python python-dev libcgal.dev wget

    cd /opt
    wget http://downloads.sourceforge.net/foam/OpenFOAM-2.4.0.tgz
    tar -xzf OpenFOAM-2.4.0.tgz
    rm OpenFOAM-2.4.0.tgz
    sed -i -e 's/^\(cgal_version=\).*/\1cgal-system/' OpenFOAM-2.4.0/etc/config/CGAL.sh
    cd OpenFOAM-2.4.0
    find src applications -name "*.L" -type f | xargs sed -i -e 's=\(YY\_FLEX\_SUBMINOR\_VERSION\)=YY_FLEX_MINOR_VERSION < 6 \&\& \1='
    mkdir -p /opt/ThirdParty-2.4.0/platforms/linux64Gcc/cgal-system
    mkdir -p /opt/ThirdParty-2.4.0/platforms/linux64Gcc/boost-system

    export FOAM_INST_DIR=/opt
    source /opt/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=32
    ./Allwmake
    ./Allwmake
