Reduce only build-related ROS packages - reduce docker image size
I am building a custom ROS docker image to deploy it on a ubuntu xenial embedded board. The Dockerfile is shown below. When I build the container, the size is about 1,7 GB (which is not nuch bigger than a ros:kinetic-ros-core image anyway.
BUT I need it to be smaller!!! My suggestion is, that it might be possible to remove/uninstall those ROS packages and other sw which is only necessary for building my packages, but not needed after running "catkin build".
Does anyone know how this is done? When I try "apt remove ..." with e.g. the "ros-kinetic-roslint" package, even runtime relevant stuff gets removed. Help, please!
FROM ubuntu
LABEL version="0.0.4"
ENV ROS_DISTRO kinetic
ENV CATKIN_WS=/root/catkin_ws
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 421C365BD9FF1F717815A3895523BAEEB01FA116
RUN echo "deb http://packages.ros.org/ros/ubuntu xenial main" > /etc/apt/sources.list.d/ros-latest.list
RUN apt-get update && \
apt-get -y --quiet --no-install-recommends install --allow-unauthenticated \
build-essential \
gcc \
g++ \
cmake \
make \
libusb-1.0-0-dev \
python-wstool \
python-catkin-tools \
ros-kinetic-cpp-common \
ros-kinetic-actionlib \
ros-kinetic-actionlib-msgs \
ros-kinetic-bond \
ros-kinetic-bondcpp \
ros-kinetic-catkin \
ros-kinetic-class-loader \
ros-kinetic-cmake-modules \
ros-kinetic-gencpp \
ros-kinetic-geneus \
ros-kinetic-genlisp \
ros-kinetic-genmsg \
ros-kinetic-gennodejs \
ros-kinetic-genpy \
ros-kinetic-geometry-msgs \
ros-kinetic-image-transport \
ros-kinetic-message-filters \
ros-kinetic-message-generation \
ros-kinetic-message-runtime \
ros-kinetic-nav-msgs \
ros-kinetic-nodelet \
ros-kinetic-pluginlib \
ros-kinetic-rosbag \
ros-kinetic-rosbag-storage \
ros-kinetic-rosbuild \
ros-kinetic-rosclean \
ros-kinetic-rosconsole \
ros-kinetic-roscpp \
ros-kinetic-roscpp-serialization \
ros-kinetic-roscpp-traits \
ros-kinetic-rosgraph \
ros-kinetic-rosgraph-msgs \
ros-kinetic-roslaunch \
ros-kinetic-roslib \
ros-kinetic-roslint \
ros-kinetic-roslz4 \
ros-kinetic-rosmaster \
ros-kinetic-rosout \
ros-kinetic-rospack \
ros-kinetic-rosparam \
ros-kinetic-rospy \
ros-kinetic-rostest \
ros-kinetic-rostime \
ros-kinetic-rostopic \
ros-kinetic-rosunit \
ros-kinetic-sensor-msgs \
ros-kinetic-smclib \
ros-kinetic-std-msgs \
ros-kinetic-std-srvs \
ros-kinetic-tf2 \
ros-kinetic-tf2-msgs \
ros-kinetic-tf2-py \
ros-kinetic-tf2-ros \
ros-kinetic-topic-tools \
ros-kinetic-xmlrpcpp \
ros-kinetic-mav-comm \
ros-kinetic-mav-msgs \
ros-kinetic-image-common \
ros-kinetic-visualization-msgs \
libopencv-dev && \
rm -rf /var/lib/apt/lists/*
# copy my local src directory to the docker image
ADD src /root/catkin_ws/src
WORKDIR $CATKIN_WS
RUN catkin config --install --extend=/opt/ros/kinetic -DCMAKE_BUILD_TYPE=Release && \
catkin build --summarize
RUN rm -rf /root/catkin_ws/src
RUN rm -rf /root/catkin_ws/build
RUN rm -rf /root/catkin_ws/logs
RUN rm -rf /root/catkin_ws/devel
RUN strip --strip-all $(find /root/catkin_ws/install -name "*.so"); exit 0
RUN echo 'source "$CATKIN_WS/install/setup.bash"' >> ~/.bashrc
CMD ["bash"]