Skip to content
Snippets Groups Projects
Select Git revision
  • main default
1 result

devenv.Dockerfile

Blame
  • devenv.Dockerfile 4.43 KiB
    ARG ROS_DISTRO
    FROM osrf/ros:${ROS_DISTRO}-desktop-full
    
    ARG EXT_SHELL
    RUN echo "Building devenv for ROS" $ROS_DISTRO "with shell" $EXT_SHELL
    
    # Avoid warnings by switching to noninteractive
    ENV DEBIAN_FRONTEND=noninteractive
    
    # Import the key in order to be able to use the packages from the repository
    # RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 7E72C5B4111A50084C63C9489E7A9B1D990CF897
    # NOV - 2023
    RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4B63CF8FDE49746E98FA01DDAD19BAB3CBF125EA
    
    # Setup environment
    RUN apt-get update && apt-get install -y apt-utils
    
    RUN apt-get install -y \
        locales \
        && sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen en_US.UTF-8
    ENV LANG en_US.UTF-8
    ENV LANGUAGE en_US:en
    ENV LC_ALL en_US.UTF-8
    
    # Configure apt and install ubuntu-base packages
    RUN apt-get update && \
        apt-get -y install --no-install-recommends \
        apt-transport-https \
        ca-certificates \
        curl \
        dbus-x11 \
        gnupg-agent \
        software-properties-common \
        dialog 2>&1 \
        checkinstall \
        # clang
        clang-format clang-tidy clang-tools clang \
        libc++-dev libc++1 libc++abi-dev \
        libc++abi1 libclang-dev libclang1  \
        libomp-dev libomp5 lld lldb \
        llvm-dev llvm-runtime llvm \
        # ccmake
        cmake-curses-gui \
        direnv \
        gawk \
        gdb \
        git \
        git-lfs \
        less \
        nano \
        net-tools \
        openssh-client \
        trash-cli \
        valgrind \
        wget \
        xterm
    
    # Install pip3 and packages
    RUN apt-get install -y \
        python3-pip \
        && pip3 install sqlite_utils \
        && pip3 install conan==1.59 \
        && pip3 install transforms3d \
        && conan config set general.revisions_enabled=1 \
        && conan profile new default --detect > /dev/null \
        && conan profile update settings.compiler=gcc default
    
    # Install zsh if requested
    RUN if [ "$EXT_SHELL" = "zsh" ]; \
        then \
            apt-get -y install zsh; \
        fi
    
    # Configure system to look for debian packages in the Artifactory repository
    COPY auth.conf /etc/apt/auth.conf.d/tecnalia.conf
    RUN curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add -
    
    # Configure rosdep
    RUN sh -c "echo 'yaml https://git.code.tecnalia.com/tecnalia_robotics-public/gitlab_templates/raw/master/rosdistro/rosdep_tecnalia.yaml' \
        >> /etc/ros/rosdep/sources.list.d/20-default.list"
    
    # Install docker-ce
    # RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
    # RUN add-apt-repository \
    #     "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    # RUN apt-get update && apt-get -y install \
    #     docker-ce \
    #     docker-ce-cli \
    #     containerd.io \
    #     docker-compose-plugin
    
    # Copy the requirements.txt file into the container
    WORKDIR /tmp/dependencies/
    COPY /ws_dependencies/* ./
    
    # Install the packages listed in ${ROS_DISTRO}_requirements.txt
    RUN if [ -f "${ROS_DISTRO}_requirements.txt" ]; \
        then \
            # apt-get update && \
            # grep -v '^#' ${ROS_DISTRO}_requirements.txt | xargs apt-get install -y && \
            # apt-get clean;\
            apt-get update && \
            awk '/^# APT-GET PACKAGES/,/^# PIP PACKAGES/' ${ROS_DISTRO}_requirements.txt | grep -v '^#' | xargs apt-get install -y && \
            apt-get clean; \
        fi
    
    # Install pip packages
    RUN if [ -f "${ROS_DISTRO}_requirements.txt" ]; \
        then \
            awk '/^# PIP PACKAGES/,0' ${ROS_DISTRO}_requirements.txt | grep -v '^#' | xargs -r -n1 pip install ;\
        fi
    
    RUN rm -rf *
    
    # Install extra libs from .deb files
    WORKDIR /tmp/srcs/
    COPY /extra_libs/* ./
    
    # Enviroment tools based on ubuntu version
    RUN if [ -f "common_libs.txt" ]; \
        then \
            grep -v '^#' common_libs.txt | xargs dpkg -i ;\
        fi
    
    # Extra libs, e.g. vtk-7.1_20221201-1_amd64.deb
    RUN if [ -f "${ROS_DISTRO}_libs.txt" ]; \
        then \
            grep -v '^#' ${ROS_DISTRO}_libs.txt | xargs dpkg -i ;\
        fi
    
    RUN rm -rf *
    RUN apt-get --reinstall install -y libnotify-bin notify-osd
    
    # Update this date to re-run the image final update
    LABEL image.date=17-11-2023
    
    # Update final image
    RUN apt-get update \
        && apt-get -y upgrade \
        && apt-get -y autoremove \
        && apt-get -y autoclean
    
    # Set entrypoint
    COPY ./ros_entrypoint.sh /
    RUN chmod a+x /ros_entrypoint.sh
    
    ENV ROS_DISTRO "${ROS_DISTRO}"
    
    ENV EXT_SHELL "${EXT_SHELL}"
    ENV RUNNING_IN_DOCKER true
    
    # Switch back to dialog for any ad-hoc use of apt-get
    ENV DEBIAN_FRONTEND=
    
    ARG SHELL
    ENV SHELL "${SHELL}"
    
    ENTRYPOINT ["/ros_entrypoint.sh"]
    CMD $EXT_SHELL