Skip to content

Commit

Permalink
Merge pull request #95 from usdot-fhwa-stol/release/cabin
Browse files Browse the repository at this point in the history
Release/cabin
  • Loading branch information
kjrush authored Jul 29, 2022
2 parents c218fac + b1a5af4 commit 188bd63
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
# Pull docker image from docker hub
# XTERM used for better catkin_make output
docker:
- image: usdotfhwastol/autoware.ai:carma-system-4.1.0
- image: usdotfhwastol/autoware.ai:carma-system-4.2.0
user: carma
environment:
TERM: xterm # use xterm to get full display output from build
Expand Down
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@
# License for the specific language governing permissions and limitations under
# the License.

FROM usdotfhwastol/autoware.ai:carma-system-4.1.0 as setup
FROM usdotfhwastol/autoware.ai:carma-system-4.2.0 as setup

ARG ROS1_PACKAGES=""
ENV ROS1_PACKAGES=${ROS1_PACKAGES}
ARG ROS2_PACKAGES=""
ENV ROS2_PACKAGES=${ROS2_PACKAGES}

RUN mkdir ~/src
COPY --chown=carma . /home/carma/src/
RUN ~/src/docker/checkout.bash
RUN ~/src/docker/install.sh

FROM usdotfhwastol/autoware.ai:carma-system-4.1.0
FROM usdotfhwastol/autoware.ai:carma-system-4.2.0


ARG BUILD_DATE="NULL"
Expand Down
62 changes: 61 additions & 1 deletion docker/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,59 @@ while [[ $# -gt 0 ]]; do
COMPONENT_VERSION_STRING=develop
shift
;;
--ros-1-packages|--ros1)
ROS1_PACKAGES=""
shift
;;
--ros-2-packages|--ros2)
ROS2_PACKAGES=""
shift
;;
*)
# Var test based on Stack Overflow question: https://stackoverflow.com/questions/5406858/difference-between-unset-and-empty-variables-in-bash
# Asker: green69
# Answerer: geekosaur
if [ "${ROS2_PACKAGES+set}" = "set" ]; then
ROS2_PACKAGES="$ROS2_PACKAGES $arg"
elif [ "${ROS1_PACKAGES+set}" = "set" ]; then
ROS1_PACKAGES="$ROS1_PACKAGES $arg"
else
echo "Unknown argument $arg..."
exit -1
fi
shift
;;
esac
done

if [[ ! -z "$ROS1_PACKAGES$ROS2_PACKAGES" ]]; then
echo "Performing incremental build of image to rebuild packages: $ROS1_PACKAGES $ROS2_PACKAGES..."

echo "Updating Dockerfile references to use most recent image as base image"
# Trim of docker image LS command sourced from
# https://stackoverflow.com/questions/50625619/why-doesnt-the-cut-command-work-for-a-docker-image-ls-command
# Question Asker: Chris F
# Question Answerer: Arount
MOST_RECENT_IMAGE_DATA=$(docker image ls | grep $IMAGE | tr -s ' ')

if [[ -z "$MOST_RECENT_IMAGE_DATA" ]]; then
echo No prior image exists to use as base, an initial image must be built first before attempting incremental build.
exit -1
fi

MOST_RECENT_IMAGE_HASH=$(echo $MOST_RECENT_IMAGE_DATA | cut -d " " -f 3)
MOST_RECENT_IMAGE_ORG=$(echo $MOST_RECENT_IMAGE_DATA | cut -d " " -f 1 | cut -d "/" -f 1)
MOST_RECENT_IMAGE_TAG=$(echo $MOST_RECENT_IMAGE_DATA | cut -d " " -f 2)
MOST_RECENT_IMAGE_DATE=$(echo $MOST_RECENT_IMAGE_DATA | cut -d " " -f 4,5,6)

echo Using $MOST_RECENT_IMAGE_TAG $MOST_RECENT_IMAGE_HASH $MOST_RECENT_IMAGE_DATE as base for partial build...

sed -i "s|^FROM[[:space:]]*[^[:space:]]*|FROM $MOST_RECENT_IMAGE_HASH|I" ../Dockerfile

COMPONENT_VERSION_STRING="SNAPSHOT"
USERNAME="local"
fi

if [[ -z "$COMPONENT_VERSION_STRING" ]]; then
COMPONENT_VERSION_STRING=$("./get-component-version.sh")
fi
Expand All @@ -61,8 +111,18 @@ if [[ $COMPONENT_VERSION_STRING = "develop" ]]; then
--build-arg VERSION="$COMPONENT_VERSION_STRING" \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +”%Y-%m-%dT%H:%M:%SZ”` .
elif [[ $COMPONENT_VERSION_STRING = "SNAPSHOT" ]]; then
docker build --network=host --no-cache -t $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING \
--build-arg ROS1_PACKAGES="$ROS1_PACKAGES" \
--build-arg ROS2_PACKAGES="$ROS2_PACKAGES" \
--build-arg VERSION="$COMPONENT_VERSION_STRING" \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +”%Y-%m-%dT%H:%M:%SZ”` .
else
docker build --no-cache -t $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING \
#The addition of --network=host was a fix for a DNS resolution error that occured
#when running the platform inside an Ubuntu 20.04 virtual machine. The error and possible soliutions are
# discussed here: https://github.com/moby/moby/issues/41003
docker build --network=host --no-cache -t $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING \
--build-arg VERSION="$COMPONENT_VERSION_STRING" \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +”%Y-%m-%dT%H:%M:%SZ”` .
Expand Down
4 changes: 2 additions & 2 deletions docker/checkout.bash
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ if [[ "$BRANCH" = "develop" ]]; then
git clone https://github.com/usdot-fhwa-stol/carma-msgs.git ${dir}/src/CARMAMsgs --branch $BRANCH
git clone https://github.com/usdot-fhwa-stol/carma-utils.git ${dir}/src/CARMAUtils --branch $BRANCH
else
git clone https://github.com/usdot-fhwa-stol/carma-msgs.git ${dir}/src/CARMAMsgs --branch carma-system-4.1.0
git clone https://github.com/usdot-fhwa-stol/carma-utils.git ${dir}/src/CARMAUtils --branch carma-system-4.1.0
git clone https://github.com/usdot-fhwa-stol/carma-msgs.git ${dir}/src/CARMAMsgs --branch carma-system-4.2.0
git clone https://github.com/usdot-fhwa-stol/carma-utils.git ${dir}/src/CARMAUtils --branch carma-system-4.2.0
fi
21 changes: 15 additions & 6 deletions docker/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,25 @@
# the License.

# Source ros2
source /opt/ros/foxy/setup.bash
if [[ ! -z "$ROS2_PACKAGES" ]]; then
echo "Sourcing previous build for incremental build start point..."
source /opt/carma/install/setup.bash
else
echo "Sourcing base image for full build..."
source /opt/ros/foxy/setup.bash
fi

# Get driver
sudo apt-get update && sudo apt install curl gnupg2 lsb-release
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

# Install the driver
sudo apt install ros-foxy-velodyne-driver -y
# Install pointcloud conversion package
sudo apt-get install ros-foxy-velodyne-pointcloud
# Install the driver and pointcloud conversion package
sudo apt install ros-foxy-velodyne-driver -y ros-foxy-velodyne-pointcloud
# Build wrapper
cd ~
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-up-to velodyne_lidar_driver_wrapper driver_shutdown_ros2
if [[ ! -z "$ROS2_PACKAGES" ]]; then
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-above $ROS2_PACKAGES
else
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-up-to velodyne_lidar_driver_wrapper driver_shutdown_ros2
fi

0 comments on commit 188bd63

Please sign in to comment.