Skip to content

Commit

Permalink
check: setting up kong
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashansa-K committed Feb 12, 2025
1 parent 7bcbf7b commit 38c6fb7
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
63 changes: 63 additions & 0 deletions .ci/setup_kong_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
set -e

KONG_IMAGE=${KONG_IMAGE:-kong}
NETWORK_NAME=deck-test

PG_CONTAINER_NAME=pg
DATABASE_USER=kong
DATABASE_NAME=kong
KONG_DB_PASSWORD=kong
KONG_PG_HOST=pg

GATEWAY_CONTAINER_NAME=kong

waitContainer() {
for try in {1..100}; do
echo "waiting for $1"
docker exec --user root $2 $3 && break;
sleep 0.2
done
}

# create docker network
docker network create $NETWORK_NAME

# Start a PostgreSQL container
docker run --rm -d --name $PG_CONTAINER_NAME \
--network=$NETWORK_NAME \
-p 5432:5432 \
-e "POSTGRES_USER=$DATABASE_USER" \
-e "POSTGRES_DB=$DATABASE_NAME" \
-e "POSTGRES_PASSWORD=$KONG_DB_PASSWORD" \
postgres:9.6

waitContainer "PostGres" $PG_CONTAINER_NAME pg_isready

# Prepare the Kong database
docker run --rm --network=$NETWORK_NAME \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=$KONG_PG_HOST" \
-e "KONG_PG_PASSWORD=$KONG_DB_PASSWORD" \
-e "KONG_PASSWORD=$KONG_DB_PASSWORD" \
$KONG_IMAGE kong migrations bootstrap

# Start Kong Gateway
docker run -d --name $GATEWAY_CONTAINER_NAME \
--network=$NETWORK_NAME \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=$KONG_PG_HOST" \
-e "KONG_PG_USER=$DATABASE_USER" \
-e "KONG_PG_PASSWORD=$KONG_DB_PASSWORD" \
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
-e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
-e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
-e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
-p 8000:8000 \
-p 8443:8443 \
-p 127.0.0.1:8001:8001 \
-p 127.0.0.1:8444:8444 \
$KONG_IMAGE

waitContainer "Kong" $GATEWAY_CONTAINER_NAME "kong health"
2 changes: 1 addition & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
with:
go-version-file: go.mod
- name: Setup Kong
run: make setup-kong
run: make setup-kong-new
- name: Run integration tests
run: make test-integration
continue-on-error: ${{ matrix.kong_image == 'kong/kong:master' }}
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ generate-cli-docs:
setup-kong:
bash .ci/setup_kong.sh

.PHONY: setup-kong-new
setup-kong:
bash .ci/setup_kong_check.sh

.PHONY: setup-kong-ee
setup-kong-ee:
bash .ci/setup_kong_ee.sh
Expand Down

0 comments on commit 38c6fb7

Please sign in to comment.