FROM ubuntu:jammy

ARG VERSION

ENV DEBIAN_FRONTEND=noninteractive

# Set locale
RUN apt-get update && \
    apt-get install -y locales libcurl4-openssl-dev curl wget zstd jq lsb-release mariadb-client iproute2 && \
    apt-get install -y ca-certificates apt-transport-https software-properties-common gnupg2 procps lsof && \
    localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

ENV LANG=en_US.UTF-8

# Add Centreon repositories and their public key
RUN echo "deb https://packages.centreon.com/ubuntu-standard-${VERSION}-testing/ jammy main" | tee -a /etc/apt/sources.list.d/centreon-testing.list && \
    echo "deb https://packages.centreon.com/ubuntu-plugins-testing/ jammy main" | tee -a /etc/apt/sources.list.d/centreon-plugins-testing.list && \
    wget -O- https://apt-key.centreon.com | gpg --dearmor | tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1 && \
    apt-get update

# Install required packages and Robotframework
RUN apt-get update && \
    apt-get install -y \
    python3 \
    python3-dev \
    python3-pip \
    python3-venv

# Create a virtual environment and install Robot Framework
RUN python3 -m venv /opt/robotframework-env && \
    /opt/robotframework-env/bin/pip install --no-cache-dir \
    robotframework \
    robotframework-examples \
    robotframework-databaselibrary \
    robotframework-requests \
    robotframework-jsonlibrary \
    pymysql

# Clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Set the PATH to include the virtual environment
ENV PATH="/opt/robotframework-env/bin:$PATH"
