chore(dev): linux dev support workaround (#2076)

This commit is contained in:
Florian Forster 2021-07-27 21:55:30 +02:00 committed by GitHub
parent adac3eaf2d
commit 291b04ee1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 11 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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
#######################

View File

@ -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
```