diff --git a/.dockerignore b/.dockerignore index 3783768c7e..25c2ae904f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,6 +6,7 @@ **/Dockerfile /k8s/ /docs/ +!/docs/docs/guides/installation/run/docker-compose.yaml /console/node_modules/ /console/src/app/proto/generated/ /console/tmp/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0e652407c1..ce2fb8fe6a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -10,6 +10,7 @@ release: before: hooks: - docker build -f build/grpc/Dockerfile -t zitadel-base:local . + - docker build -f build/zitadel/Dockerfile . -t zitadel-test-base --target go-test - 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/* ." diff --git a/build/e2e/Dockerfile b/build/e2e/Dockerfile index e52b5d2461..3144476a3d 100644 --- a/build/e2e/Dockerfile +++ b/build/e2e/Dockerfile @@ -1,11 +1,12 @@ -ARG GO_VERSION=1.17 - ####################### ## run initialize setup step for ZITADEL tests ####################### -FROM golang:${GO_VERSION} -WORKDIR /go/src/github.com/zitadel/zitadel +FROM zitadel-test-base + +# Invalidate caches when only test code changes +COPY ./docs/docs/guides/installation/run/docker-compose.yaml ./docs/docs/guides/installation/run/docker-compose.yaml +COPY ./cmd/e2e-setup ./cmd/e2e-setup +COPY ./e2e ./e2e # copy setup -COPY . . -RUN e2e/e2e-setup-compose.sh +CMD e2e/e2e-setup.sh diff --git a/console/cypress.sh b/console/cypress.sh index ac7046a935..4cd4a0228f 100755 --- a/console/cypress.sh +++ b/console/cypress.sh @@ -8,7 +8,11 @@ shift export projectRoot=".." -set -a; source $ENVFILE; set +a +if [ -z ${ENVFILE:x} ]; then + echo "Not sourcing any env file" +else + set -a; source $ENVFILE; set +a +fi NPX="" if ! command -v cypress &> /dev/null; then diff --git a/e2e/compose.env b/e2e/compose.env index 72b76dd0f9..af809c8cf2 100644 --- a/e2e/compose.env +++ b/e2e/compose.env @@ -8,5 +8,5 @@ ZITADEL_E2E_LOGINPOLICYUSERPW=Password1! ZITADEL_E2E_MACHINEKEYPATH="${projectRoot}/.keys/e2e.json" ZITADEL_E2E_BASEURL="http://zitadel:8080" ZITADEL_E2E_OTHERZITADELIDPINSTANCE=false -ZITADEL_E2E_ZITADELPROJECTRESOURCEID="bignumber-$(echo -n $(${projectRoot}/e2e/docker-compose.sh exec --no-TTY db cockroach sql --database zitadel --insecure --execute "select aggregate_id from eventstore.events where event_type = 'project.added' and event_data = '{\"name\": \"ZITADEL\"}';" --format tsv) | cut -d " " -f 2)" -ZITADEL_E2E_INSTANCEID="$(echo -n $(${projectRoot}/e2e/docker-compose.sh exec --no-TTY db cockroach sql --database zitadel --insecure --execute "select aggregate_id from eventstore.events where event_type = 'instance.added' and event_data = '{\"name\": \"Localhost\"}';" --format tsv) | cut -d " " -f 2)" +ZITADEL_EXTERNALDOMAIN=zitadel +ZITADEL_S3DEFAULTINSTANCE_CUSTOMDOMAIN=zitadel diff --git a/e2e/docker-compose-overwrite.yaml b/e2e/docker-compose-overwrite.yaml index 9bbb966a66..ee5720c091 100644 --- a/e2e/docker-compose-overwrite.yaml +++ b/e2e/docker-compose-overwrite.yaml @@ -1,12 +1,37 @@ services: zitadel: image: 'zitadel:${BUILD_DATE}' + environment: + # TODO: ugly + ZITADEL_EXTERNALDOMAIN: zitadel + ZITADEL_S3DEFAULTINSTANCE_CUSTOMDOMAIN: zitadel + + e2e-setup: + command: ./e2e/e2e-setup.sh + build: + dockerfile: ./build/e2e/Dockerfile + context: .. + container_name: e2e-setup + env_file: + - ./compose.env + environment: + ZITADEL_DATABASE_HOST: db + depends_on: + zitadel: + condition: service_started + networks: + - 'zitadel' +# TODO: See PR #3816 +# condition: 'service_healthy' + e2e: image: cypress/included:10.3.0 #build: ./e2e container_name: cypress depends_on: - - zitadel + e2e-setup: + condition: 'service_completed_successfully' + command: ./cypress.sh run # note: inside e2e container, the network allows accessing # "zitadel" host under name "zitadel" # so "curl http://web" would return whatever the webserver @@ -25,5 +50,6 @@ services: # rebuild required). working_dir: /e2e volumes: - - /Users/christianjakob/caos/internal/zitadel/console:/e2e -# - ./console/cypress.config.js:/e2e/cypress.config.js + - ./console:/e2e + networks: + - 'zitadel' diff --git a/e2e/docker-compose-workdir.yaml b/e2e/docker-compose-workdir.yaml new file mode 100644 index 0000000000..66457347f7 --- /dev/null +++ b/e2e/docker-compose-workdir.yaml @@ -0,0 +1,5 @@ +# By using this file as first --file argument to docker compose, compose uses this directory as working directory + +version: '3.8' + + diff --git a/e2e/docker-compose.sh b/e2e/docker-compose.sh index 5756d70678..dc43755c9f 100755 --- a/e2e/docker-compose.sh +++ b/e2e/docker-compose.sh @@ -1,3 +1,3 @@ #!/bin/bash -COMPOSE_DOCKER_CLI_BUILD=1 docker compose --file ${projectRoot}/docs/docs/guides/installation/run/docker-compose.yaml --file ${projectRoot}/e2e/docker-compose-overwrite.yaml "$@" +COMPOSE_DOCKER_CLI_BUILD=1 docker compose --file ${projectRoot}/e2e/docker-compose-workdir.yaml --file ${projectRoot}/docs/docs/guides/installation/run/docker-compose.yaml --file ${projectRoot}/e2e/docker-compose-overwrite.yaml --env-file ${projectRoot}/e2e/compose.env "$@" diff --git a/e2e/e2e-setup-compose.sh b/e2e/e2e-setup-compose.sh deleted file mode 100755 index 63ed3a3ced..0000000000 --- a/e2e/e2e-setup-compose.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -set -ex - -export projectRoot="." - -set -a -source ./e2e/compose.env -set +a - -go run ./cmd/e2e-setup/*.go "$@" diff --git a/e2e/e2e-setup.sh b/e2e/e2e-setup.sh index 87424d89ae..2573f32d88 100755 --- a/e2e/e2e-setup.sh +++ b/e2e/e2e-setup.sh @@ -4,8 +4,14 @@ set -ex export projectRoot="." -set -a -source ./e2e/local.env -set +a +ENVFILE=$1 + +if [ -z ${ENVFILE:x} ]; then + echo "Not sourcing any env file" +else + set -a; source $ENVFILE; set +a +fi + +env go run ./cmd/e2e-setup/*.go "$@" diff --git a/e2e/install.sh b/e2e/install.sh index 827f7ad757..5fb83446f0 100755 --- a/e2e/install.sh +++ b/e2e/install.sh @@ -1,5 +1,7 @@ #!/bin/bash +# TODO: ONLY BUILD HERE AND PRINT BUILT IMAGE TO STDOUT? + set -e export projectRoot="."