Skip to content

Commit

Permalink
Merge pull request #91 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 91a00ae + ba13619 commit 4eafeb4
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 8 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/carma-base:carma-system-4.1.0
- image: usdotfhwastol/carma-base:carma-system-4.2.0
user: carma
environment:
TERM: xterm
Expand Down
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
# License for the specific language governing permissions and limitations under
# the License.

FROM usdotfhwastol/carma-base:carma-system-4.1.0 as base
FROM usdotfhwastol/carma-base:carma-system-4.2.0 as base
FROM base 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/CARMAAvtVimbaDriver
RUN ~/src/CARMAAvtVimbaDriver/docker/checkout.bash
Expand Down
64 changes: 62 additions & 2 deletions docker/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
USERNAME=usdotfhwastol

cd "$(dirname "$0")"
IMAGE=carma-avt-vimba-driver
IMAGE=$(basename `git rev-parse --show-toplevel`)

echo ""
echo "##### $IMAGE Docker Image Build Script #####"
Expand All @@ -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 ~/src/carma-msgs --branch $BRANCH --depth 1
git clone https://github.com/usdot-fhwa-stol/carma-utils.git ~/src/carma-utils --branch $BRANCH --depth 1
else
git clone https://github.com/usdot-fhwa-stol/carma-msgs.git ${dir}/src/carma-msgs --branch carma-system-4.1.0
git clone https://github.com/usdot-fhwa-stol/carma-utils.git ${dir}/src/carma-utils --branch carma-system-4.1.0
git clone https://github.com/usdot-fhwa-stol/carma-msgs.git ${dir}/src/carma-msgs --branch carma-system-4.2.0
git clone https://github.com/usdot-fhwa-stol/carma-utils.git ${dir}/src/carma-utils --branch carma-system-4.2.0
fi
15 changes: 13 additions & 2 deletions docker/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
# License for the specific language governing permissions and limitations under
# the License.

source /opt/ros/noetic/setup.bash
if [[ ! -z "$ROS1_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/noetic/setup.bash
fi

cd ~/
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
if [[ ! -z "$ROS1_PACKAGES" ]]; then
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-above $ROS1_PACKAGES
else
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
fi

0 comments on commit 4eafeb4

Please sign in to comment.