corda/experimental/kubernetes/bin/build-and-publish/bft-notary.sh
2018-03-27 13:45:44 +01:00

46 lines
964 B
Bash
Executable File

#!/bin/sh
set -eux
target_rev=${1:-"HEAD"}
container_name=${2:-"bft-notary"}
registry=${CONTAINER_REGISTRY:-"ctesting.azurecr.io"}
export rev=$(git rev-parse $target_rev)
rev_short=$(git rev-parse --short $target_rev)
workspace=$(mktemp -d -t kubeform-XXX)
git worktree add $workspace $rev
cp -r build-contexts $workspace
docker_cmd="docker"
if [ "$(uname)" = "Linux" ]; then
docker_cmd="sudo docker"
fi
patch="0001-Read-corda-rev-from-environment-var.patch"
cp $patch $workspace
container_image="${registry}/r3/${container_name}:$rev"
(
cd $workspace
git apply $patch
./gradlew --debug jar
JAR=$(ls -S node/capsule/build/libs | head -n1)
cp node/capsule/build/libs/$JAR build-contexts/bft-notary/corda.jar
cd build-contexts/bft-notary
${docker_cmd} build -t $container_image .
${docker_cmd} push $container_image
)
mkdir -p built
echo "r3-$rev_short $container_image" > built/bft-notary.txt
rm -rf $workspace
git worktree prune