zitadel/e2e/install.sh

62 lines
1.4 KiB
Bash
Raw Normal View History

2022-07-07 17:28:46 +02:00
#!/bin/bash
2022-07-25 15:24:16 +02:00
# TODO: ONLY BUILD HERE AND PRINT BUILT IMAGE TO STDOUT?
2022-07-07 17:28:46 +02:00
set -e
2022-07-20 13:15:32 +02:00
export projectRoot="."
2022-07-07 17:28:46 +02:00
DO_BUILD=1
DO_DEPLOY=1
2022-07-08 10:07:17 +02:00
while getopts 'bd:' OPTION; do
2022-07-07 17:28:46 +02:00
case "$OPTION" in
b)
echo "skipping build"
DO_BUILD=0
;;
d)
echo "skipping deployment"
DO_DEPLOY=0
;;
?)
echo "script usage: $(basename \$0) [-b] [-d] [-t]" >&2
echo "-b skip build"
echo "-d skip deployment"
exit 1
;;
esac
done
shift "$(($OPTIND -1))"
if [ "$DO_BUILD" -eq "1" ]; then
# build the zitadel binary
GOOS="linux" GOARCH="amd64" goreleaser build --snapshot --single-target --rm-dist
2022-07-07 17:28:46 +02:00
fi
# extract some metadata for building and tagging the docker image
function extract_metadata ()
{
cat .artifacts/goreleaser/$1 | jq -r $2
}
BUILD_DATE="$(extract_metadata metadata.json '.date')"
# Use simple local date
BUILD_DATE="${BUILD_DATE%.*}"
# Replace colons and plus signs
export BUILD_DATE="${BUILD_DATE//:/_}"
if [ "$DO_BUILD" -eq "1" ]; then
BUILD_PATH="$(dirname $(extract_metadata artifacts.json '.[0].path'))"
BUILD_VERSION="$(extract_metadata metadata.json '.version')"
# build the docker image
2022-07-08 10:07:17 +02:00
DOCKER_BUILDKIT=1 docker build --file ./build/Dockerfile --tag zitadel:latest --tag zitadel:$BUILD_VERSION --tag zitadel:$BUILD_DATE $BUILD_PATH
2022-07-07 17:28:46 +02:00
fi
if [ "$DO_DEPLOY" -eq "1" ]; then
# run cockroach and zitadel
2022-07-25 16:33:53 +02:00
./e2e/docker-compose.sh up --build --detach
2022-07-07 17:28:46 +02:00
fi