content: ARG BASE_IMAGE=192.168.3.15:9595/base/python:3.10-22.04
  #################################
  #   Librealsense Builder Stage  #
  #################################
  FROM $BASE_IMAGE AS librealsense-builder
  
  ARG LIBRS_VERSION=2.55.1
  # Make sure that we have a version number of librealsense as argument
  RUN test -n "$LIBRS_VERSION"
  
  # To avoid waiting for input during package installation
  ENV DEBIAN_FRONTEND=noninteractive
  
  # Builder dependencies installation
  RUN apt-get update \
      && apt-get install -qq -y --no-install-recommends \
      build-essential \
      cmake \
      git \
      wget \
      libssl-dev \
      libusb-1.0-0-dev \
      pkg-config \
      libgtk-3-dev \
      libglfw3-dev \
      libgl1-mesa-dev \
      libglu1-mesa-dev \
      libudev-dev \
      curl \
      python3 \
      python3-dev \
      libpython3-dev \
      ca-certificates \
      v4l-utils \
      && rm -rf /var/lib/apt/lists/*
  
  # Download sources
  WORKDIR /usr/src
  RUN wget  https://github.com/IntelRealSense/librealsense/archive/refs/tags/v${LIBRS_VERSION}.tar.gz -O librealsense.tar.gz
  RUN tar -zxf librealsense.tar.gz \
      && rm librealsense.tar.gz
  RUN ln -s /usr/src/librealsense-$LIBRS_VERSION /usr/src/librealsense
  
  # Build and install
  RUN cd /usr/src/librealsense \
      # && bash ./scripts/setup_udev_rules.sh \
      # && bash ./scripts/patch-realsense-ubuntu-lts-hwe.sh \
      && mkdir build && cd build \
      && cmake \
      -DCMAKE_C_FLAGS_RELEASE="${CMAKE_C_FLAGS_RELEASE} -s" \
      -DCMAKE_CXX_FLAGS_RELEASE="${CMAKE_CXX_FLAGS_RELEASE} -s" \
      -DCMAKE_INSTALL_PREFIX=/opt/librealsense \
      -DBUILD_GRAPHICAL_EXAMPLES=OFF \
      -DBUILD_PYTHON_BINDINGS:bool=true \
      -DCMAKE_BUILD_TYPE=Release ../ \
      && make -j$(($(nproc)-1)) all \
      && make install
  
  ######################################
  #   librealsense Base Image Stage    #
  ######################################
  FROM ${BASE_IMAGE} AS librealsense
  
  # Copy binaries from builder stage
  COPY --from=librealsense-builder /opt/librealsense /usr/local/
  # COPY --from=librealsense-builder /usr/lib/python3/dist-packages/pyrealsense2 /usr/lib/python3/dist-packages/pyrealsense2
  COPY --from=librealsense-builder /usr/src/librealsense/config/99-realsense-libusb.rules /etc/udev/rules.d/
  COPY --from=librealsense-builder /usr/src/librealsense/config/99-realsense-d4xx-mipi-dfu.rules /etc/udev/rules.d/
  # ENV PYTHONPATH=$PYTHONPATH:/usr/local/lib
  
  # Install dep packages
  RUN apt-get update \
      && apt-get install -y --no-install-recommends \
      libusb-1.0-0 \
      udev \
      apt-transport-https \
      ca-certificates \
      curl \
      software-properties-common \
      && rm -rf /var/lib/apt/lists/*
  
  # Shows a list of connected Realsense devices
  # CMD [ "rs-enumerate-devices", "--compact" ]
  