FROM ubuntu:20.04

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && apt-get install -y apt-utils git curl cmake g++ gfortran python3 python3-numpy python3-scipy python3-pip swig clang-tidy emacs-nox valgrind texlive texlive-latex-recommended texlive-latex-extra texinfo libreoffice fonts-cmu libpetsc-complex-dev libslepc-complex3.12-dev python3-dev 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 libxft-dev libxinerama-dev libxcursor-dev libxfixes-dev libocct-foundation-dev libocct-data-exchange-dev libocct-ocaf-dev libopenmpi-dev libboost-dev cargo clang gcovr ftp && apt-get clean

RUN pip3 install twine

# to convert a .fodt document, simply run
# soffice --headless --convert-to pdf Tutorials.fodt

# this does not work anymore
# RUN cargo install --root /opt/cargo mdbook --version "^0.3.8"

# mmg
RUN git clone https://github.com/MmgTools/mmg.git && cd mmg && mkdir build && cd build && cmake -DBUILD_SHARED_LIBS=1 .. && make -j8 && make install && cd .. && rm -rf mmg

# this does not work anymore
# libomp with ThreadSanitizer support (see https://gitlab.onelab.info/gmsh/gmsh/-/issues/1250)
# RUN curl -LO https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-12.0.0.tar.gz && tar xf llvmorg-12.0.0.tar.gz && cd llvm-project-llvmorg-12.0.0 && mkdir build && cd build && cmake -DLIBOMP_TSAN_SUPPORT=1 ../openmp && cmake --build . --target install && cd .. && rm -rf llvm-project-llvmorg-12.0.0

# "docker build --build-arg REBUILD_GMSH=somethingnew"
RUN REBUILD_GMSH=${REBUILD_GMSH} && git clone https://gitlab.onelab.info/gmsh/gmsh.git && cd gmsh && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_BUILD_SHARED=1 -DENABLE_PRIVATE_API=1 .. && make -j4 shared && make install/fast && cd .. && rm -rf gmsh

VOLUME ["/etc/gitlab-runner"]
RUN useradd -ms /bin/bash validator
USER validator
WORKDIR /home/validator
RUN mkdir -p ~/.ssh
RUN chmod 700 ~/.ssh
ENV PATH="/opt/cargo/bin:${PATH}"
