###############################################################################
# Dockerfile used to make gitlab.linphone.org:4567/bc/public/external/sofia-sip/bc-dev-rocky10:20260513_add_bind
###############################################################################

FROM rockylinux/rockylinux:10

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

# Install common general tools
RUN dnf install -y sudo vim wget curl-minimal

# Configure additional repositories
RUN dnf install -y \
        epel-release \
        dnf-plugins-core \
  # Code Ready Builder
 && dnf config-manager -y --set-enabled crb

# Update
RUN dnf makecache --refresh \
 && dnf -y update \
 # Install development tools
 && dnf -y install \
        ccache \
        clang \
        cmake \
        git \
        libasan \
        libev-devel \
        libubsan \
        libuv-devel \
        make \
        ninja-build \
        openssl-devel \
        yasm \
        zlib-devel \
    # Dependencies for tests
        check-devel \
        subunit-devel \
        bind \
        bind-utils \
    # Dependencies of test coverage
        python3 \
        python3-pip \
        lcov \
 && dnf -y clean all

# Dependency of test coverage (converts lcov format to cobertura so Gitlab can display code coverage for files in diff view)
RUN pip install lcov_cobertura

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

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

ENV PATH=$PATH:/home/bc/.local/bin

ENV PS1='\[\e[34m\]\u@bc-dev-rocky10>\[\e[0m\] '

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


# Example build commands
#
# export CC=gcc
# export CXX=g++
# export BUILD_DIR_NAME="build.rocky10"
# cd sofia-sip/
# cmake -S . -B ./$BUILD_DIR_NAME -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -DENABLE_COVERAGE=ON
# cd $BUILD_DIR_NAME
# cmake --build .
