Skip to content

Commit

Permalink
updated build-image and checkout.sh for test option (#31)
Browse files Browse the repository at this point in the history
* updated build-image and checkout.sh for test option

* updated for develop option

* added -r to checkout.sh
  • Loading branch information
jtbaird authored Apr 22, 2020
1 parent 3c0a5f3 commit 515e72f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
name: Pull Deps
command: |
source ${INIT_ENV}
./src/CARMAAvtVimbaDriver/docker/checkout.sh ${PWD}
./src/CARMAAvtVimbaDriver/docker/checkout.sh -r ${PWD}
- run:
name: Build Driver
command: |
Expand Down
21 changes: 17 additions & 4 deletions docker/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ while [[ $# -gt 0 ]]; do
PUSH=true
shift
;;
-d|--develop)
USERNAME=usdotfhwastoldev
COMPONENT_VERSION_STRING=develop
shift
;;
esac
done

Expand All @@ -50,10 +55,18 @@ echo "Building docker image for $IMAGE version: $COMPONENT_VERSION_STRING"
echo "Final image name: $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING"

cd ..
docker build --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”` .
if [[ $COMPONENT_VERSION_STRING = "test" ]]; then
sed "s|usdotfhwastol|$USERNAME|g; s|:[0-9]*\.[0-9]*\.[0-9]*|:$COMPONENT_VERSION_STRING|g; s|checkout.sh|checkout.sh -d|g" \
Dockerfile | docker build -f - --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”` .
else
docker build --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”` .
fi

TAGS=()
TAGS+=("$USERNAME/$IMAGE:$COMPONENT_VERSION_STRING")
Expand Down
23 changes: 19 additions & 4 deletions docker/checkout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,23 @@
set -ex

dir=~
if [[ -n ${1} ]]; then
dir=${1}
fi
while [[ $# -gt 0 ]]; do
arg="$1"
case $arg in
-d|--develop)
BRANCH=develop
shift
;;
-r|--root)
dir=$2
shift
shift
;;
esac
done

git clone https://github.com/usdot-fhwa-stol/carma-msgs.git ${dir}/src/CARMAMsgs --branch CARMAMsgs_1.1.0 --depth 1
if [[ "$BRANCH" = "develop" ]]; then
git clone https://github.com/usdot-fhwa-stol/carma-msgs.git ~/src/CARMAMsgs --branch $BRANCH --depth 1
else
git clone https://github.com/usdot-fhwa-stol/carma-msgs.git ${dir}/src/CARMAMsgs --branch CARMAMsgs_1.1.0 --depth 1
fi
7 changes: 7 additions & 0 deletions hooks/pre_build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if [[ "$SOURCE_BRANCH" = "develop" ]]; then
# add -t flag to checkout.sh and update image dependencies
sed -i "s|/checkout.sh|/checkout.sh -d|g; s|usdotfhwastol|usdotfhwastoldev|g; s|:[0-9]*\.[0-9]*\.[0-9]*|:develop|g" \
Dockerfile
fi

0 comments on commit 515e72f

Please sign in to comment.