# Base image for cmpt 745 projects
FROM ubuntu:jammy 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 \
         python3 \
         python3-pip \
         gcc-12 \
         g++-12 \
         gdb \
         openjdk-11-jdk \
         maven \
    && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 1000 \
    && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 1000 \
    \
    && `# Install the latest version of LLVM` \
    && wget https://apt.llvm.org/llvm.sh \
    && chmod +x llvm.sh \
    && ./llvm.sh 15 \
    && rm llvm.sh \
    && update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 1000 \
    && update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 1000 \
    && update-alternatives --install /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-15 1000 \
    && update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-15 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" \
    \
    && pip install angr frida-tools\
    \
    && `# Final cleanup` \
    && rm -rf /var/lib/apt/lists/*

RUN groupadd student && \
    useradd -g student -c "Default student user" student
USER student
WORKDIR /home/student

