diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0e652407c1..845a2be03e 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -10,7 +10,7 @@ release: before: hooks: - docker build -f build/grpc/Dockerfile -t zitadel-base:local . - - docker build -f build/zitadel/Dockerfile . -t zitadel-go-test --target go-codecov -o .artifacts/codecov +# - docker build -f build/zitadel/Dockerfile . -t zitadel-go-test --target go-codecov -o .artifacts/codecov - docker build -f build/zitadel/Dockerfile . -t zitadel-go-base --target go-copy -o .artifacts/grpc/go-client - sh -c "cp -r .artifacts/grpc/go-client/* ." - docker build -f build/console/Dockerfile . -t zitadel-npm-base --target npm-copy -o .artifacts/grpc/js-client diff --git a/e2e/docker-compose-overwrite.yaml b/e2e/docker-compose-overwrite.yaml new file mode 100644 index 0000000000..3b086bd25e --- /dev/null +++ b/e2e/docker-compose-overwrite.yaml @@ -0,0 +1,4 @@ +services: + zitadel: + image: 'zitadel:${BUILD_DATE}' + diff --git a/e2e/run.sh b/e2e/run.sh new file mode 100755 index 0000000000..e23d3d110d --- /dev/null +++ b/e2e/run.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +set -e + +DO_BUILD=1 +DO_DEPLOY=1 +DO_TEST=1 + +while getopts 'bdt:' OPTION; do + case "$OPTION" in + b) + echo "skipping build" + DO_BUILD=0 + ;; + d) + echo "skipping deployment" + DO_DEPLOY=0 + ;; + s) + echo "skipping tests" + DO_TEST=0 + ;; + ?) + echo "script usage: $(basename \$0) [-b] [-d] [-t]" >&2 + echo "-b skip build" + echo "-d skip deployment" + echo "-t skip tests" + exit 1 + ;; + esac +done +shift "$(($OPTIND -1))" + +if [ "$DO_BUILD" -eq "1" ]; then + # build the zitadel binary + goreleaser build --snapshot --single-target --rm-dist +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 + docker build --file ./build/Dockerfile --tag zitadel:latest --tag zitadel:$BUILD_VERSION --tag zitadel:$BUILD_DATE $BUILD_PATH +fi + +if [ "$DO_DEPLOY" -eq "1" ]; then + # run cockroach and zitadel + docker compose --file ./docs/docs/guides/installation/run/docker-compose.yaml --file ./e2e/docker-compose-overwrite.yaml up --detach +fi