diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..3b71d6f49 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,34 @@ +ARG ROS_DISTRO +ARG UBUNTU_VERSION +FROM osrf/ros:${ROS_DISTRO}-desktop-${UBUNTU_VERSION} + +RUN echo "deb http://packages.ros.org/ros-testing/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list +RUN apt-get update && apt-get install -y wget git +RUN wget http://packages.ros.org/ros.key -O - | apt-key add - + +RUN apt-get update && apt-get dist-upgrade -y && apt-get install -y \ + python-catkin-tools \ + python-pip \ + python-rosdep \ + python-setuptools \ + python-wstool + +RUN pip install 'pip==9.0.3' && \ + pip install 'setuptools==44.1.0' + +ARG ROS_DISTRO +RUN cd ~ && \ + mkdir -p ros/${ROS_DISTRO}/src && \ + cd ros/${ROS_DISTRO}/src && \ + wstool init && \ + wstool set jsk-ros-pkg/jsk_visualization https://github.com/jsk-ros-pkg/jsk_visualization.git -v master --git -y && \ + wstool up -j 2 + +RUN rosdep update --include-eol-distros + +# /opt/ros/${ROS_DISTRO}/share can be changed after rosdep install, so we run it 3 times. +RUN for i in $(seq 3); do rosdep install --rosdistro ${ROS_DISTRO} -r -y -i --from-paths /opt/ros/${ROS_DISTRO}/share ~/ros/${ROS_DISTRO}/src; done + +RUN . /opt/ros/${ROS_DISTRO}/setup.sh && \ + cd ~/ros/${ROS_DISTRO} && \ + catkin build; \ diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..024503773 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,10 @@ +# docker for jsk_visualization + +## Usage + +``` +# melodic +docker build --build-arg ROS_DISTRO=melodic --build-arg UBUNTU_VERSION=bionic -t jskrobotics/jsk_visualization:melodic-latest . +# kinetic +docker build --build-arg ROS_DISTRO=kinetic --build-arg UBUNTU_VERSION=xenial -t jskrobotics/jsk_visualization:kinetic-latest . +``` diff --git a/docker/hooks/build b/docker/hooks/build new file mode 100644 index 000000000..aca86b60d --- /dev/null +++ b/docker/hooks/build @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -eu + +[[ ${DOCKER_TAG} =~ ([a-z]+)-([0-9a-z.]+)$ ]] +ROS_DISTRO=${BASH_REMATCH[1]}; + +if [[ ${ROS_DISTRO} = "kinetic" ]]; then + UBUNTU_VERSION="xenial"; +elif [[ ${ROS_DISTRO} = "indigo" ]]; then + UBUNTU_VERSION="trusty"; +fi + +docker build --build-arg ROS_DISTRO=${ROS_DISTRO} \ + --build-arg UBUNTU_VERSION=${UBUNTU_VERSION} \ + -t ${IMAGE_NAME} .