###############################################################################
# Dockerfile used to make gitlab.linphone.org:4567/bc/public/flexisip/bc-dev-ubuntu-24-04:20260619_remove_nghttp2_asio
###############################################################################

FROM ubuntu:24.04
RUN userdel -r ubuntu

LABEL org.opencontainers.image.authors="Belledonne Communications <flexisip@belledonne-communications.com>"

  # Update
RUN apt-get -y update \
  # Install common tools
 && apt-get -y install sudo \
                       vim \
                       wget \
                       file \
                       curl \
                       software-properties-common \
                     # Install development tools
                       ccache \
                       clang-20 \
                       cmake \
                       doxygen \
                       elfutils \
                       gcc-14 \
                       g++-14 \
                       gdb \
                       git \
                       llvm \
                       make \
                       ninja-build \
                       python3 \
                       python3-pystache \
                       python3-six \
                       yasm \
                     # Install all dependencies needed for Flexisip
                       libsystemd-dev \
                       libssl-dev \
                       libboost-dev \
                       libboost-system-dev \
                       libboost-thread-dev \
                       libcpp-jwt-dev \
                       libhiredis-dev \
                       libjansson-dev \
                       libjsoncpp-dev \
                       libsqlite3-dev \
                       libpq-dev \
                       libmariadb-dev \
                       libmariadb-dev-compat \
                       mariadb-server \
                       libnghttp2-dev \
                       libsnmp-dev \
                       libxerces-c-dev \
                       libsrtp2-dev \
                       libgsm1-dev \
                       libopus-dev \
                       libmbedtls-dev \
                       libspeex-dev \
                       libspeexdsp-dev \
                       libxml2-dev \
                       redis-server \
                       squid \
                     # Dependencies of the B2BUA
                       libvpx-dev \
                     # Dependencies of CPack (to build the .deb)
                       dpkg-dev \
  # Clean
 && apt-get -y autoremove \
 && apt-get -y clean

# Update gcc and clang alternatives
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 10 \
    && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 10 \
    &&update-alternatives --install /usr/bin/clang clang /usr/bin/clang-20 10 \
    && update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-20 10

# Configure user bc
RUN useradd -ms /bin/bash bc && \
    echo 'bc:cotcot' | chpasswd && \
    echo 'bc ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# Switch for 'bc' user
USER bc
WORKDIR /home/bc

# CVE-2022-24765, from git 2.35.2 onward
RUN git config --global --add safe.directory *

# Example build commands
#
# cd flexisip/
# export CC=gcc
# export CXX=g++
# export BUILD_DIR_NAME="build.ubuntu24"
# cmake -S . -B ./$BUILD_DIR_NAME -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="$PWD/$BUILD_DIR_NAME/install" -DENABLE_UNIT_TESTS=ON
# cd $BUILD_DIR_NAME
# cmake --build . --target install
# LSAN_OPTIONS="suppressions=../sanitizer_ignore.txt" bin/flexisip_tester --resource-dir "../tester/"
