# Build Image for Gitlab CI

FROM ubuntu:20.04

MAINTAINER Elliott Slaughter <slaughter@cs.stanford.edu>

ENV DEBIAN_FRONTEND noninteractive

RUN dpkg --add-architecture i386 && \
    apt-get update -qq && \
    apt-get install -qq apt-transport-https ca-certificates software-properties-common wget && \
    add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
    add-apt-repository ppa:pypy/ppa -y && \
    apt-get update -qq && \
    apt-get install -qq \
      build-essential pkg-config gfortran git time wget curl \
      libpython3-dev python3-pip pypy3 \
      g++-9 g++-10 g++-11 \
      gfortran-9 gfortran-10 gfortran-11 \
      gcc-multilib g++-multilib \
      clang-12 libclang-12-dev llvm-12-dev libomp-12-dev \
      libedit-dev libncurses5-dev libffi-dev libpfm4-dev libxml2-dev \
      zlib1g-dev zlib1g-dev:i386 \
      mpich libmpich-dev \
      mesa-common-dev \
      libblas-dev liblapack-dev libhdf5-dev \
      libssl-dev \
      libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libfontconfig-dev \
      gdb vim && \
    apt-get clean

RUN pip3 install --upgrade 'pip>=22,<23' && \
    pip3 install --upgrade 'setuptools>=62,<63' 'setuptools_rust>=1.3,<1.4' && \
    pip3 install cffi github3.py 'numpy>=1.22,<1.23' 'cryptography>=37,<38' 'pandas>=1.4,<1.5' daff tabulate

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.67.1 -y

RUN wget https://github.com/Kitware/CMake/releases/download/v3.16.9/cmake-3.16.9-Linux-x86_64.tar.gz && \
    echo "96d79367dcafb47d606573a4687021d3cb18dd53d83458fc1d6d9c89bf31b553  cmake-3.16.9-Linux-x86_64.tar.gz" | shasum --check && \
    tar xfzC cmake-3.16.9-Linux-x86_64.tar.gz /usr/local --strip-components=1 && \
    rm cmake-3.16.9-Linux-x86_64.tar.gz

RUN git clone https://github.com/terralang/terra.git && \
    cd terra/build && \
    cmake -DCMAKE_INSTALL_PREFIX=/usr/local/terra12 .. && \
    make install -j8 && \
    rm -rf terra
