Skip to content

Instantly share code, notes, and snippets.

@anug7
Last active May 15, 2020 08:08
Show Gist options
  • Save anug7/29faf53269f0f7645317598294a641b9 to your computer and use it in GitHub Desktop.
Save anug7/29faf53269f0f7645317598294a641b9 to your computer and use it in GitHub Desktop.
ROS-melodic-ubuntu1604-Dockerfile
FROM ubuntu:16.04
#Inspired from https://github.com/erlerobot/gym-gazebo/blob/master/Dockerfile
RUN apt install -y -q --no-install-recommends software-properties-common
RUN add-apt-repository -y ppa:deadsnakes/ppa
RUN apt update
RUN apt install -y -q --no-install-recommends curl python3.6-dev wget
RUN curl -s https://bootstrap.pypa.io/get-pip.py | python3.6 -
# Gazebo related things
RUN sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable xenial main" > /etc/apt/sources.list.d/gazebo-stable.list'
RUN wget http://packages.osrfoundation.org/gazebo.key -O - | apt-key add -
RUN apt update
RUN apt install gazebo8 -y
RUN apt install -y libgazebo8-dev
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
RUN apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
RUN echo "deb http://packages.ros.org/ros/ubuntu xenial main" > /etc/apt/sources.list.d/ros-latest.list
RUN apt update
RUN apt install -y libgpgme11-dev
ENV ROS_DISTRO melodic
RUN apt -y install cmake gcc g++ git
RUN pip3 install -U rosdep rosinstall_generator wstool rosinstall
RUN pip3 install rospkg catkin_pkg empy
RUN pip3 install defusedxml netifaces pycryptodomex gnupg
RUN rosdep init && rosdep update
RUN mkdir -p ~/tmp/catkin/src
RUN cd ~/tmp/catkin && rosinstall_generator image_common cv_bridge --rosdistro melodic \
--deps --wet-only --tar > melodic-ros_comm-wet.rosinstall
# Fetch packages
RUN cd ~/tmp/catkin && wstool init -j1 src melodic-ros_comm-wet.rosinstall
RUN apt install libconsole-bridge-dev -y
RUN apt install -y libtinyxml-dev liblz4-dev libbz2-dev liburdfdom-dev libpoco-dev \
libtinyxml2-dev
RUN pip3 install sip
RUN pip3 install numpy
RUN apt install liblapacke-dev
# Install OpenCV
RUN apt install -y libeigen3-dev libyaml-cpp-dev unzip
# Refer: https://www.mail-archive.com/[email protected]/msg1644551.html
RUN sed -n -i 'p;14a #include <boost/next_prior.hpp>' /usr/include/yaml-cpp/node/detail/iterator.h
#Refer: https://codeyarns.github.io/tech/2017-01-24-how-to-build-boost-on-linux.html
RUN cd ~/tmp && wget https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.bz2
RUN cd ~/tmp && tar -xvf boost_1_73_0.tar.bz2
RUN cd ~/tmp/boost_1_73_0/ && ./bootstrap.sh --with-python=python3.6 --prefix=/usr/local cxxflags="-std=c++14" && ./b2 install --prefix=/usr/local link=shared threading=multi runtime-link=shared cxxflags="-std=c++14"
RUN mkdir ~/tmp/opencv/
RUN wget -O ~/tmp/opencv/opencv.zip https://github.com/opencv/opencv/archive/3.4.2.zip
RUN wget -O ~/tmp/opencv/opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/3.4.2.zip
WORKDIR ~/tmp/opencv/
RUN unzip -a ~/tmp/opencv/opencv.zip -d ~/tmp/opencv/
RUN unzip -a ~/tmp/opencv/opencv_contrib.zip ~/tmp/opencv/
RUN cd ~/tmp/opencv/opencv-3.4.2 && mkdir build && cd build && cmake -DWITH_TBB=ON -DBUILD_EXAMPLES=OFF -DENABLE_PRECOMPILED_HEADERS=OFF -DOPENCV_EXTRA_MODULES_PATH=~/tmp/opencv/opencv_contrib-3.4.2/modules -D BUILD_NEW_PYTHON_SUPPORT=ON -D BUILD_opencv_python3=ON -D HAVE_opencv_python3=ON -D PYTHON3_EXECUTABLE=$(which python3.6) -DWITH_BOOST=ON -DCMAKE_INSTALL_PREFIX=/usr/local ..
RUN cd ~/tmp/opencv/opencv-3.4.2/build && make -j3 && make install
# Install SIP
RUN cd ~/tmp/ && wget https://src.fedoraproject.org/lookaside/pkgs/sip/sip-4.17.tar.gz/ca51677770fa62dd5087877688cf97ba/sip-4.17.tar.gz
RUN cd ~/tmp && tar -xvf sip-4.17.tar.gz && cd sip-4.17 && python3.6 ./configure.py
RUN cd ~/tmp/sip-4.17 && make -j4 && make install
# Install SDL
RUN apt install libsdl-image1.2-dev
RUN apt install libsdl-dev
# Cmake
RUN apt install libarchive13 libjsoncpp1 liblzo2-2
# Cmake latest version
RUN wget https://github.com/Kitware/CMake/releases/download/v3.17.2/cmake-3.17.2-Linux-x86_64.sh -O ~/tmp/
RUN cd ~/tmp && chmod +x cmake-3.17.2-Linux-x86_64.sh && ./cmake-3.17.2-Linux-x86_64.sh --skip-license --prefix=/usr/
RUN ldconfig
# catkibn uses python command. So update python to point to python3.6
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
RUN ln -s /usr/local/lib/libboost_python-py36.so /usr/local/lib/libboost_python3.so
RUN cd ~/tmp/catkin && ./src/catkin/bin/catkin_make_isolated -DPYTHON_VERSION=3.6 --install -DCMAKE_BUILD_TYPE=Release -DCATKIN_ENABLE_TESTING=OFF -DCMAKE_INSTALL_PREFIX=/opt/ros/melodic -DCMAKE_CXX_FLAGS=" -std=c++11 " -j 3
RUN cd ~/tmp && wget https://github.com/IntelRealSense/librealsense/archive/v2.31.0.zip
RUN cd ~/tmp && unzip -a v2.31.0.zip
RUN cd ~/tmp/librealsense-2.31.0 && mkdir build && cd build && cmake -DBUILD_PYTHON_BINDINGS:bool=true -DPYTHON_EXECUTABLE=`which python3.6` -DBUILD_EXAMPLES:bool=false -DCMAKE_INSTALL_PREFIX=/opt/intel/rls ..
RUN cd ~/tmp/librealsense-2.31.0/build && make install -j4
RUN rm -rf ~/tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment