Created
February 21, 2020 22:39
-
-
Save alagalah/b393da8bae30a2a23d72171dab607cd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## | |
# Expects things to look like: | |
#. . <--- WORK | |
#. ├── datacollector | |
#. ├── datacollector-docker | |
WORK="${WORK:-$(PWD)}" | |
get_branch_name () { | |
branch_name="$(git symbolic-ref HEAD 2>/dev/null)" || | |
branch_name="(unnamed branch)" # detached HEAD | |
branch_name=${branch_name##refs/heads/} | |
branch_name=$(basename $branch_name) | |
echo $branch_name | |
} | |
#build | |
pushd $WORK/datacollector | |
#Name the image.. .usually the branch - | |
VERSION=$(find $WORK/datacollector/dist/target -name streamsets -type f | awk -F "streamsets-datacollector-" '{print $3}' | awk -F "\/bin" '{print $1}') | |
echo "TAG:" $VERSION | |
#mvn clean package -Prelease -DskipTests | |
# Get to folder above bin. | |
cd $(dirname $(find $WORK/datacollector/dist/target -name streamsets -type f));cd ../.. | |
[[ -f streamsets-datacollector-docker-$VERSION.tgz ]] || tar cvzf streamsets-datacollector-docker-$VERSION.tgz streamsets-datacollector* | |
#clean up any existing tgz in docker dir | |
rm $WORK/datacollector-docker/*-$VERSION.tgz | |
#copy the tarball over | |
cp streamsets-datacollector-docker-$VERSION.tgz $WORK/datacollector-docker | |
docker rmi streamsets/datacollector:$VERSION | |
popd | |
pushd $WORK/datacollector-docker | |
docker build -t streamsets/datacollector:$VERSION --build-arg SDC_VERSION=$VERSION . | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment