Skip to content
Snippets Groups Projects
Select Git revision
  • e071116bbc7b49e86405eaed8904b6669e803843
  • main default
2 results

ssh.Dockerfile

Blame
  • ssh.Dockerfile 4.89 KiB
    ### FIRST LAYER TO DOWNLOAD GIT REPOS
    FROM osrf/ros:melodic-desktop-full as intermediate
    
    RUN apt-get update
    
    #################################
    # Add ssh private key
    RUN apt-get install -y ssh
    
    ARG SSH_PRIVATE_KEY
    RUN mkdir ~/.ssh/
    RUN echo "${SSH_PRIVATE_KEY}" > /root/.ssh/id_rsa
    RUN chmod 600 ~/.ssh/id_rsa
    RUN ssh-keyscan git.code.tecnalia.com >> /root/.ssh/known_hosts && chmod 644 /root/.ssh/known_hosts
    
    #Print SSH_PRIVATE_KEY (for test)
    #RUN echo "${SSH_PRIVATE_KEY}"
    
    RUN apt-get install -y git
    
    # Create workspace
    RUN mkdir -p /root/dev_ws/src
    WORKDIR /root/dev_ws/src
    
    # Install python-wstools
    RUN apt-get install -y wget
    RUN wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
    RUN apt-get update
    RUN apt-get install -y python-catkin-tools
    # Clone main package
    WORKDIR /root/dev_ws/src
    RUN git clone git@git.code.tecnalia.com:tecnalia_robotics/kawada/kawada_lab_application.git
    # Populate dependencies with rosinstall
    RUN mkdir /root/dev_ws/src/dependencies
    WORKDIR /root/dev_ws/src/dependencies
    RUN wstool init && wstool merge ../kawada_lab_application/.rosinstall && wstool update
    
    
    ### SECOND LAYER TO BUILD DEV-ENV
    FROM osrf/ros:melodic-desktop-full
    
    ENV ROS_DISTRO melodic
    # Avoid warnings by switching to noninteractive
    ENV DEBIAN_FRONTEND=noninteractive
    
    # Setup environment
    RUN apt-get update && 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 packages
    RUN apt-get update \
        && apt-get -y install --no-install-recommends \
        apt-transport-https \
        ca-certificates \
        curl \
        gnupg-agent \
        software-properties-common \
        apt-utils dialog 2>&1 \
        #
        # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
        # Install the https transport support package for The Artifactory debian repository
        && apt-get -y install git \
        git-lfs \
        nano \
        iproute2 \ 
        procps \
        lsb-release \
        curl \
        cmake \
        && apt-get -y install openssh-client \
        python-catkin-tools \
        python-osrf-pycommon \
        ros-${ROS_DISTRO}-rosmon \
        xterm \
        && rosdep init || true \
        && rm -rf /var/lib/apt/lists/*
    
    # 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 install -y \
        docker-ce-cli \
        && rm -rf /var/lib/apt/lists/*
    
    # Configure system to look for debian packages in the Artifactory repository
    ARG USER_API_KEY_ARTIFACTS_TECNALIA
    RUN sh -c "echo \
    	'deb https://${USER_API_KEY_ARTIFACTS_TECNALIA}@artifact.tecnalia.com/artifactory/tecnalia-robotics-debian xenial main' \
        >> /etc/apt/sources.list.d/tecnalia.list"
    
    # 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
    
    # 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"
    
    # Packages installed as dependecies of kawada_lab_aplication 
    RUN apt-get update && apt-get install -y \
        ros-melodic-ros-control-boilerplate \
        ros-melodic-moveit-planners-ompl \
        ros-melodic-moveit-plugins \
        ros-melodic-moveit-ros-visualization \
        ros-melodic-moveit-ros-planning-interface \
        ros-melodic-moveit-setup-assistant \
        ros-melodic-moveit-fake-controller-manager \
        ros-melodic-moveit-kinematics \
        ros-melodic-moveit-ros-move-group \
        ros-melodic-ur-msgs \
        ros-melodic-eigen-stl-containers \
        ros-melodic-industrial-robot-simulator \
        ros-melodic-move-base-msgs \
        ros-melodic-srdfdom \
        ros-melodic-joint-state-publisher-gui \
        python-pyside \
        python-lxml \
        python-qt4 \
        python-qt4-dev \
        libshiboken-dev \
        shiboken \
        libpyside-dev \
        libcomedi-dev \
        libmodbus-dev \
        libcanberra-gtk-module \
        libcanberra-gtk0 \
        && rm -rf /var/lib/apt/lists/*
    
    # Update final image
    RUN apt-get update && apt-get -y upgrade 
    
    # Install helping packages
    RUN apt-get install -y terminator
    RUN apt-get install -y less iputils-ping
    
    # Source ros setup.sh
    RUN /bin/sh . "/opt/ros/$ROS_DISTRO/setup.bash"
    
    # Install python-wstools
    RUN apt-get install -y wget
    RUN wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
    RUN apt-get update
    RUN apt-get install -y python-catkin-tools
    
    # Copy workspace with dependencies created in the previous layer
    COPY --from=intermediate /root/dev_ws /root/dev_ws
    WORKDIR /root/dev_ws
    RUN catkin init && catkin config --extend /opt/ros/melodic && catkin build
    
    # Add source ros to .bashrc
    RUN echo "#ROS\nsource /opt/ros/melodic/setup.bash\nsource /root/dev_ws/devel/setup.bash" >> /root/.bashrc