# Base image for cmpt 373 projects.
# Build with:
#    docker buildx build -t nsumner/cmpt373:fall2026 .
FROM ubuntu:resolute AS build

# General version configuration
ENV LLVM_VERSION=22
ENV GCC_VERSION=16
ENV JAVA_VERSION=25
ENV BOOST_VERSION=1_90_0

# Flutter configuration
ENV FLUTTER_CHANNEL=stable
ENV FLUTTER_VERSION=3.44.1
ENV FLUTTER_HOME=/opt/flutter

ENV PATH="$PATH:$FLUTTER_HOME/bin:$EMSCRIPTEN_HOME/bin"

RUN apt-get update -y \
    && DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
        software-properties-common \
    && add-apt-repository ppa:ubuntu-toolchain-r/ppa -y \
    && apt-get update -y \
    \
    && `# Start with all normal ubuntu packages` \
    && DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
         apt-utils \
         ca-certificates \
         lsb-release \
         gnupg2 \
         wget \
         curl \
         git \
         make \
         ninja-build \
         cmake \
         valgrind \
         heaptrack \
         cppcheck \
         libncurses-dev \
         libsqlite3-dev \
         libftxui-dev \
         zlib1g-dev \
         xz-utils \
         bzip2 \
         googletest \
         nlohmann-json3-dev \
         libfmt-dev \
         python3 \
         python3-pip \
         openjdk-${JAVA_VERSION}-jdk \
         gcc-$GCC_VERSION \
         g++-$GCC_VERSION \
         gdb \
         gcovr \
         clang-$LLVM_VERSION \
         clang-format-$LLVM_VERSION \
         clang-tidy-$LLVM_VERSION \
         clang-tools-$LLVM_VERSION \
         libboost-all-dev \
    && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 1000 \
    && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION 1000 \
    && update-alternatives --install /usr/bin/clang   clang   /usr/bin/clang-$LLVM_VERSION   1000 \
    && update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-$LLVM_VERSION 1000 \
    \
    `# Install emscripten` \
    && cd /opt \
    && git clone https://github.com/emscripten-core/emsdk.git \
    && cd emsdk \
    && ./emsdk install latest \
    && ./emsdk activate latest \
    && ./emsdk construct_env \
    && echo ". /opt/emsdk/emsdk_env.sh" >> /etc/profile \
    \
    && `# Install spdlog` \
    && git clone https://github.com/gabime/spdlog.git \
    && cd spdlog && mkdir build && cd build \
    && cmake .. && make -j && make install \
    && cd ../.. && rm -rf ./spdlog \
    \
    && `# Final cleanup` \
    && rm -rf /var/lib/apt/lists/*

#RUN git clone https://github.com/flutter/flutter.git $FLUTTER_HOME \
#    && cd $FLUTTER_HOME \
#    && git checkout $FLUTTER_CHANNEL \
#    && git pull \
#    && flutter doctor

# Enable web support
#RUN flutter config --enable-web
