Skip to content

Commit

Permalink
Add gateway health check and run yaml getter in release (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmthecoder committed Aug 29, 2024
1 parent ee34f2d commit 8de9485
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/create-sdk-on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
version: '27.x'
- name: Install Dependencies
run: yarn install
- name: Start Docker Container
run: yarn run:dev
- name: Get SDK YAML
run: ./docker/wait-for-healthy-gateway.sh
- name: Generate SDK
run: yarn gen-client-sdk
- name: Create Tarball
Expand Down
5 changes: 5 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ services:
depends_on:
auth-service:
condition: service_healthy
healthcheck:
test: ['CMD-SHELL', 'curl http://api-gateway:3000/ || exit 1']
interval: 2s
timeout: 10s
retries: 10

auth-service:
build:
Expand Down
16 changes: 16 additions & 0 deletions docker/wait-for-healthy-gateway.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
_wait() {
[[ $# -lt 2 ]] && {
echo "Usage: ${FUNCNAME} <timeout> </path/to/script>"; return 1
}
timeout=$(($(date +%s) + ${1}))
until [[ $2 ]] || [[ $(date +%s) -gt $timeout ]]; do
:
done
[[ $(date +%s) -gt $timeout ]] && return 1 || return 0
}

cmd='[ $(docker ps -f health=healthy -f name=juno-api-gateway -q | wc -l) -eq 1 ]' # script that only checks health
_wait 300 $cmd # maximum time to wait 300s
[[ $? -eq 0 ]] && {
wget $(docker port juno-api-gateway-1 3000)/docs-yaml
} || exit 1
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"lint": "nx run-many --target=lint --no-cloud",
"sync-protos": "node syncJunoProtos.js",
"gen-proto": "yarn workspace juno-proto install && yarn workspace juno-proto build && yarn sync-protos",
"gen-client-sdk": "yarn openapi-generator-cli generate -g typescript-node -i ./packages/api-gateway/sdk.yaml -o ./juno-client-sdk",
"gen-client-sdk": "yarn openapi-generator-cli generate -g typescript-node -i ./docs-yaml -o ./juno-client-sdk",
"preinstall": "yarn gen-proto",
"test:e2e:api-gateway-live": "GATEWAY_COMMAND=test:e2e:watch RUN_MODE=test yarn start:dev:live-all --exit-code-from api-gateway",
"test:e2e:auth-service-live": "AUTH_COMMAND=test:e2e:watch RUN_MODE=test yarn start:dev:live-all --exit-code-from auth-service auth-service",
Expand Down

0 comments on commit 8de9485

Please sign in to comment.