diff --git a/build/local/Dockerfile.started b/build/local/Dockerfile.started index ca8a3e182c..60bf416445 100644 --- a/build/local/Dockerfile.started +++ b/build/local/Dockerfile.started @@ -1,5 +1,5 @@ FROM ubuntu:latest AS started -#install dependencies +#install dependencies with a workaround for the 412 error RUN apt-get update \ && apt-get install curl -y diff --git a/build/local/clientid.sh b/build/local/clientid.sh index 54423eb334..1af0fa0c04 100644 --- a/build/local/clientid.sh +++ b/build/local/clientid.sh @@ -6,11 +6,11 @@ clientid="" while [ -z $clientid ]; do - echo "no from zitadel ==> retry" - sleep 2 + echo "no from zitadel ==> retrying in 5 seconds" + sleep 5 clientid=$(curl -s http://${HOST}:${PORT}/clientID) if [[ "$clientid" != *@zitadel* ]]; then - echo "invalid response from zitadel ==> retry" + echo "invalid response from zitadel ==> retrying in 5 seconds" clientid="" fi done diff --git a/build/local/docker-compose-local.yml b/build/local/docker-compose-local.yml index 072fa11164..ea676f1c8f 100644 --- a/build/local/docker-compose-local.yml +++ b/build/local/docker-compose-local.yml @@ -75,7 +75,7 @@ services: - keys build: context: ../.. - dockerfile: build/dockerfile + dockerfile: build/zitadel/Dockerfile target: dev-go-build args: ENV: dev @@ -126,10 +126,12 @@ services: 'start', ] - zitadel-setted-up: + zitadel-started-up: profiles: ['setup'] networks: - zitadel + extra_hosts: + host.docker.internal: host-gateway build: context: ../.. dockerfile: build/local/Dockerfile.started @@ -170,7 +172,7 @@ services: ENV: dev volumes: - ./environment.json:/console/src/assets/environment.json - command: sh -c "ng serve --host 0.0.0.0" + command: sh -c "ng serve --host 0.0.0.0 --disable-host-check" ports: - 4200:4200 diff --git a/build/local/zitadel-started.sh b/build/local/zitadel-started.sh index 5b380b1d59..10f721d7e1 100755 --- a/build/local/zitadel-started.sh +++ b/build/local/zitadel-started.sh @@ -6,15 +6,31 @@ # ------------------------------ be_status="" -fe_status="" +env_status="" +console_status="" -while [[ $be_status -ne 200 || $fe_status -ne 200 ]]; do +while [[ $be_status != 200 && $env_status != 200 ]]; do sleep 5 + ## This is a workaround for a race condition + if [[ $be_status -eq 412 ]]; then + echo "please restart the process once again to get rid of the 412 error!" + fi be_status=$(curl -s -o /dev/null -I -w "%{http_code}" host.docker.internal:${BE_PORT}/clientID) - fe_status=$(curl -s -o /dev/null -I -w "%{http_code}" host.docker.internal:${FE_PORT}/assets/environment.json) - echo "backend (${be_status}) or frontend (${fe_status}) not ready yet" + env_status=$(curl -s -o /dev/null -I -w "%{http_code}" host.docker.internal:${FE_PORT}/assets/environment.json) + echo "backend (${be_status}) or environment (${env_status}) not ready yet ==> retrying in 5 seconds" done +echo "backend and environment.json ready!" + +while [[ $console_status != 200 ]]; do + sleep 15 + console_status=$(curl -s -o /dev/null -I -w "%{http_code}" host.docker.internal:${FE_PORT}/index.html) + echo "console (${console_status}) not ready yet ==> retrying in 15 seconds" +done + +echo "console ready - please wait shortly!" +sleep 15 + echo -e "++=======================================================================================++ || || || ZZZZZZZZZZZZ II TTTTTTTTTTTT AAAA DDDDDD EEEEEEEEEE LL || @@ -35,3 +51,7 @@ echo -e "++===================================================================== || SSSSSSSSSS TT AA AA RR RR TT EEEEEEEEEE DDDDDD || || || ++=======================================================================================++" + +echo "access the console here http://localhost:${FE_PORT}" +echo "access the login here http://localhost:50003/login" +echo "access the apis here http://localhost:50002" diff --git a/build/zitadel/Dockerfile b/build/zitadel/Dockerfile index 99b0e5a09c..aa4bbc74fa 100644 --- a/build/zitadel/Dockerfile +++ b/build/zitadel/Dockerfile @@ -145,6 +145,12 @@ ARG BUILDARCH RUN CGO_ENABLED=0 GOOS=linux GOARCH=${BUILDARCH} go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o zitadel-linux-${BUILDARCH} cmd/zitadel/main.go +####################### +## Go dev build +####################### +FROM go-base as dev-go-build +ENTRYPOINT [ "go", "run", "cmd/zitadel/main.go" ] + ####################### ## Only Copy Assets ####################### diff --git a/guides/quickstart.md b/guides/quickstart.md index 7ef9c3b89e..6be2d06f61 100644 --- a/guides/quickstart.md +++ b/guides/quickstart.md @@ -23,3 +23,36 @@ COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 \ ``` For a more detailed guide take a look at the [development guide](./development.md) + +## FAQ + +### Build Errors + +If you experience strange docker error you might need to check that `buildkit` is enabled. + +Make sure to enable `"features": { "buildkit": true }` in your docker settings! + +### Error 412 + +If the line `backend (412), environment (000) or console (000) not ready yet ==> retrying in 5 seconds` contains a `412` you struck a race condition within the start process (It should exit 1 when this happens). This will be fixed in a future release. You can work around it by restarting the containers. + +```Bash +COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 \ +docker-compose -f ./build/local/docker-compose-local.yml --profile database --profile init-backend --profile init-frontend --profile backend --profile frontend --profile setup -p zitadel up +``` + +### Remove the quickstart + +```Bash +docker-compose -f ./build/local/docker-compose-local.yml --profile database --profile init-backend --profile init-frontend --profile backend --profile frontend --profile setup -p zitadel rm +``` + +If you are **confident** that you don't need to run the same ZITADEL instance again, go ahead and delete the `.keys` folder and reset the `environment.json` as well. + +```Bash +rm -rf .keys +``` + +```Bash +git reset build/local/environment.json +```