# Base image for cmpt 745 projects
FROM ubuntu:mantic AS build

RUN apt-get update \
    \
    && `# Start with all normal ubuntu packages` \
    && DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends apt-utils \
         ca-certificates \
         software-properties-common \
         lsb-release \
         gnupg2 \
         wget \
         git \
         make \
         ninja-build \
         cmake \
         valgrind \
         heaptrack \
         cppcheck \
         zlib1g-dev \
         googletest \
         libfmt-dev \
         libzstd-dev \
         python3 \
         python3-pip \
         python3-virtualenv \
         gcc-13 \
         g++-13 \
         gdb \
         openjdk-11-jdk \
         maven \
    && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 1000 \
    && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 1000 \
    \
    && `# Install the latest version of LLVM` \
    && wget https://apt.llvm.org/llvm.sh \
    && chmod +x llvm.sh \
    && ./llvm.sh 17 \
    && rm llvm.sh \
    && update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 1000 \
    && update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-17 1000 \
    && update-alternatives --install /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-17 1000 \
    && update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-17 1000 \
    && update-alternatives --install /usr/bin/opt opt /usr/bin/opt-17 1000 \
    \
    && `# Install Google Benchmark` \
    && git clone https://github.com/google/benchmark.git \
    && cd benchmark \
    && cmake -E make_directory "build" \
    && cmake -E chdir "build" cmake -DBENCHMARK_ENABLE_GTEST_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ../ \
    && cmake --build "build" --config Release \
    && cmake --install "build" \
    \
    && `# Final apt cleanup` \
    && rm -rf /var/lib/apt/lists/* \
    \
    && virtualenv --python=python3 /opt/env745 \
    && . /opt/env745/bin/activate \
    && pip install angr frida-tools clang==17.0.6

ENV PATH="/opt/env745/bin:$PATH"
