Skip to content

Instantly share code, notes, and snippets.

@eskerda
Created March 19, 2021 16:27
Show Gist options
  • Save eskerda/29e96579b984016027ff7ec13d3353f3 to your computer and use it in GitHub Desktop.
Save eskerda/29e96579b984016027ff7ec13d3353f3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# set an image
# export GOJIRA_IMAGE="some-kong-docker-image"
#####################################
# or a branch and a repo
# export GOJIRA_REPO="kong"
# export GOJIRA_TAG="name-of-the-branch"
#####################################
# or just run from within a kong
# folder (like: cd some/kong/folder; run these steps)
# on that case, run the following
# gojira build
# gojira up --alone
# gojira run make dev
# gojira snapshot
# gojira down
################################
gojira hybrid up
ADMIN_URL=$(gojira hybrid compose port kong-cp 8001)
PROXY_URL=$(gojira hybrid compose port kong-dp 8000)
>&2 echo "waiting for db"
until docker inspect $(gojira hybrid compose ps -q db) | grep healthy &> /dev/null; do sleep 0.5; done
gojira hybrid run@kong-cp kong migrations bootstrap
>&2 echo "[kong-cp] starting kong"
gojira hybrid run@kong-cp kong start
>&2 echo "[kong-dp] starting kong"
gojira hybrid run@kong-dp kong start
>&2 echo "[kong-cp] creating example service"
http POST $ADMIN_URL/services name=example host=mockbin.org
http -f POST $ADMIN_URL/services/example/routes hosts=example.com
>&2 echo "[kong-dp] waiting for config update"
until http $PROXY_URL/request/foo Host:example.com --check-status; do sleep 0.5; done
>&2 echo "killing database"
gojira hybrid compose stop db
>&2 echo "[kong-dp] scaling to 2"
gojira hybrid compose scale kong-dp=2
gojira hybrid run@kong-dp --index 2 kong start
PROXY_URL_2=$(gojira hybrid compose port --index=2 kong-dp 8000)
until http $PROXY_URL_2/request/foo Host:example.com --check-status; do sleep 0.5; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment