Skip to content

Commit

Permalink
Migrate to using rostooling/setup-ros-docker images (#68)
Browse files Browse the repository at this point in the history
* use rostooling/setup-ros-docker images instead of OSRF's ROS docker images

* be the user appropriate for the updated docker image/container

* assume default user is rosbuild, not root
  • Loading branch information
mm318 authored May 29, 2020
1 parent 29435ad commit 57d3a85
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions ce_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ then
fi
fi

[ ${ROS_DISTRO} == "kinetic" ] && UBUNTU_DISTRO=xenial || UBUNTU_DISTRO=bionic
DOCKER_IMAGE_NAME="rostooling/setup-ros-docker:ubuntu-${UBUNTU_DISTRO}-ros-${ROS_DISTRO}-ros-base-latest"

echo "using Build script, ${BUILD_SCRIPT_NAME}"
DOCKER_BUILD_SCRIPT="/shared/$(basename -- ${SCRIPT_DIR})/${BUILD_SCRIPT_NAME}"
# get a docker container from OSRF's docker hub
docker pull "ros:${ROS_DISTRO}-ros-core"
docker pull "${DOCKER_IMAGE_NAME}"
# run docker container
docker run -v "${PWD}/shared:/shared" \
-e ROS_DISTRO="${ROS_DISTRO}" \
Expand All @@ -46,21 +49,15 @@ docker run -v "${PWD}/shared:/shared" \
-e UPLOAD_SOURCES="${UPLOAD_SOURCES}" \
--name "${ROS_DISTRO}-container" \
--network=host \
-dit "ros:${ROS_DISTRO}-ros-core" /bin/bash
-dit "${DOCKER_IMAGE_NAME}" /bin/bash

# add the rosdev non-root user
docker exec "${ROS_DISTRO}-container" /bin/bash -c 'groupadd -g 999 rosdev && useradd -m -u 999 -g rosdev -G sudo rosdev'
# set the rosdev user password to rosdev
docker exec "${ROS_DISTRO}-container" /bin/bash -c 'echo "rosdev:rosdev" | chpasswd'
# allow rosdev to use sudo without password
docker exec "${ROS_DISTRO}-container" /bin/bash -c 'echo "rosdev ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers'
# make a workspace in the docker container
docker exec --user rosdev "${ROS_DISTRO}-container" /bin/bash -c 'sudo mkdir -p "/${ROS_DISTRO}_ws/src"'
docker exec "${ROS_DISTRO}-container" /bin/bash -c 'sudo mkdir -p "/${ROS_DISTRO}_ws/src"'
# copy the code over to the docker container
docker cp "${TRAVIS_BUILD_DIR}" "${ROS_DISTRO}-container":"/${ROS_DISTRO}_ws/src/"
docker exec --user rosdev "${ROS_DISTRO}-container" /bin/bash -c 'sudo chown -R rosdev "/${ROS_DISTRO}_ws"'
docker exec "${ROS_DISTRO}-container" /bin/bash -c 'sudo chown -R rosbuild "/${ROS_DISTRO}_ws"'
# execute build scripts and run test
docker exec --user rosdev "${ROS_DISTRO}"-container /bin/bash "${DOCKER_BUILD_SCRIPT}"
docker exec "${ROS_DISTRO}"-container /bin/bash "${DOCKER_BUILD_SCRIPT}"

# upload coverage report to codecov
if [ -z "${NO_TEST}" ];
Expand Down

0 comments on commit 57d3a85

Please sign in to comment.