# Build Image for Gitlab CI

FROM ubuntu:22.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 && \
    apt-get update -qq && \
    apt-get install -qq \
      build-essential pkg-config gfortran git time wget curl \
      libpython3-dev python3-pip pypy3 \
      g++-10 g++-11 g++-12 \
      gfortran-10 gfortran-11 gfortran-12 \
      gcc-multilib g++-multilib \
      clang-14 libclang-14-dev llvm-14-dev libomp-14-dev libmlir-14-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.23.5/cmake-3.23.5-linux-x86_64.tar.gz && \
    echo "bbd7ad93d2a14ed3608021a9466ae63db76a24efd1fae7a5f7798c1de7ab9344  cmake-3.23.5-linux-x86_64.tar.gz" | shasum --check && \
    tar xfzC cmake-3.23.5-linux-x86_64.tar.gz /usr/local --strip-components=1 && \
    rm cmake-3.23.5-linux-x86_64.tar.gz

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