Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #12 from USGS-EROS/jira/lcmap-1714
Browse files Browse the repository at this point in the history
updated build to include git short hash
  • Loading branch information
davidvhill authored Jan 2, 2020
2 parents c0309d3 + 704f5d6 commit 7cd7231
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BRANCH="${TRAVIS_BRANCH:-`git rev-parse --abbrev-ref HEAD | tr / -`}"
echo Branch: $BRANCH

# ...same for the commit.
COMMIT="${TRAVIS_COMMIT:-`git rev-parse HEAD`}"
COMMIT=`git rev-parse --short HEAD`
echo Commit: $COMMIT

# Version is extracted from project.clj so that a meaningful tag can
Expand All @@ -32,22 +32,20 @@ else
exit 1
fi

# Including the short commit SHA ensures uniquely identified builds
# as its possible for users to commit changes without incrementing
# version numbers, resulting new builds with the same tag
BRANCH_TAG=$REPO:$BRANCH-$VERSION-$COMMIT
echo "BRANCH_TAG: ${BRANCH_TAG}"

# Travis will build topic branches, but Docker images should not be
# built for each one because this would result in a *lot* of images
# during periods of active development.
if [ "$BRANCH" == "master" ] || [ "$BRANCH" == "develop" ] ; then

# Using the commit SHA will ensure that built images persist on
# Docker Hub unless explicitly removed. A more meaningful tag
# is also created using the <branch>-<version> but that can be
# superseded by subsequent builds.
COMMIT_TAG=$REPO:$COMMIT
BRANCH_TAG=$REPO:$BRANCH-$VERSION

echo "Building Docker image for $COMMIT_TAG ($BRANCH_TAG)"
lein uberjar
docker build -f Dockerfile -t $COMMIT_TAG .
docker tag $COMMIT_TAG $BRANCH_TAG
docker build -f Dockerfile -t $BRANCH_TAG .
docker push $REPO
echo "Building Docker image ... done"

Expand Down

0 comments on commit 7cd7231

Please # to comment.