FROM ubuntu:18.04

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && apt-get install -y git cmake python curl g++ gfortran texlive texinfo valgrind libopenblas-dev libfltk1.3-dev libfreetype6-dev libgl1-mesa-dev libxi-dev libxmu-dev mesa-common-dev tcl-dev tk-dev libhdf5-dev libcgns-dev

# -----------------------
# OpenCASCADE
# -----------------------

# could simply use apt-get install libocct-data-exchange-dev

RUN curl -L -o occ73.tgz "http://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=refs/tags/V7_3_0;sf=tgz"
RUN tar xf occ73.tgz
RUN cd occt-V7_3_0 && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_MODULE_Draw=0 -DBUILD_MODULE_Visualization=0 -DBUILD_MODULE_ApplicationFramework=0 .. && cat CMakeCache.txt && make -j8
RUN cd occt-V7_3_0/build && make install
ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH

# -----------------------
# PETSc
# -----------------------

RUN curl -O http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.10.2.tar.gz
RUN tar zxf petsc-3.10.2.tar.gz
ENV PETSC_DIR ${PWD}/petsc-3.10.2
ENV PETSC_ARCH real_mumps_seq
RUN cd ${PETSC_DIR} && ./configure --with-clanguage=cxx --with-debugging=0 --with-mpi=0 --with-mpiuni-fortran-binding=0 --download-mumps=yes --with-mumps-serial --with-shared-libraries=0 --with-x=0 --with-ssl=0 --with-scalar-type=real && make

# -----------------------
# SLEPc
# -----------------------

RUN curl -O http://slepc.upv.es/download/distrib/slepc-3.10.1.tar.gz
RUN tar zxf slepc-3.10.1.tar.gz
ENV SLEPC_DIR ${PWD}/slepc-3.10.1
RUN cd ${SLEPC_DIR} && ./configure && make

# -----------------------
# Minimal Gmsh library
# -----------------------

RUN curl -O http://gmsh.info/src/gmsh-4.0.7-source.tgz
RUN tar zxf gmsh-4.0.7-source.tgz
RUN cd gmsh-4.0.7-source && mkdir build && cd build && cmake -DDEFAULT=0 -DENABLE_PARSER=1 -DENABLE_POST=1 -DENABLE_PLUGINS=1 -DENABLE_ANN=1 -DENABLE_BLAS_LAPACK=1 -DENABLE_BUILD_LIB=1 -DENABLE_PRIVATE_API=1 .. && make -j8 lib && make install/fast

VOLUME ["/etc/gitlab-runner"]
RUN useradd -ms /bin/bash validator
USER validator
WORKDIR /home/validator
