-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bcbf7b
commit 38c6fb7
Showing
3 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters