From d3e378c8c0651133932513557dc268c5d8791760 Mon Sep 17 00:00:00 2001 From: Wangchong Zhou Date: Fri, 24 Nov 2023 15:30:13 +0800 Subject: [PATCH 1/3] fix(*) only mount logs directory and use a different prefix --- assets/docker-compose.yml | 1 + assets/pongo_entrypoint.sh | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/assets/docker-compose.yml b/assets/docker-compose.yml index afa84fad..1adff576 100644 --- a/assets/docker-compose.yml +++ b/assets/docker-compose.yml @@ -170,3 +170,4 @@ services: - ${SERVICE_NETWORK_NAME}-kong.${SERVICE_NETWORK_NAME} volumes: - ${PONGO_WD}:/kong-plugin + - ${PONGO_WD}/servroot/logs:/kong-prefix/logs diff --git a/assets/pongo_entrypoint.sh b/assets/pongo_entrypoint.sh index 3f73f9b6..6eb95e07 100755 --- a/assets/pongo_entrypoint.sh +++ b/assets/pongo_entrypoint.sh @@ -62,8 +62,7 @@ if [ -z "$KONG_DNS_RESOLVER" ]; then fi fi -# set working dir in mounted volume to be able to check the logs -export KONG_PREFIX=/kong-plugin/servroot +export KONG_PREFIX=/kong-prefix # set debug logs; specifically for the 'shell' command, tests already have it export KONG_LOG_LEVEL=debug @@ -106,14 +105,14 @@ fi # Modify the 'kong' user to match the ownership of the mounted plugin folder # Kong will not start because of permission errors if it cannot write to the -# /kong-plugin/servroot folder (which resides on the mount). +# /kong-prefix folder (which created by volume mount /kong-prefix/logs by root). # Since those permissions are controlled by the host, we update the 'kong' user # inside the container to match the UID and GID. -if [ -d /kong-plugin ]; then +if [ -d /kong-prefix ]; then KONG_UID=$(id -u kong) KONG_GID=$(id -g kong) - MOUNT_UID=$(stat -c "%u" /kong-plugin) - MOUNT_GID=$(stat -c "%g" /kong-plugin) + MOUNT_UID=$(stat -c "%u" /kong-prefix) + MOUNT_GID=$(stat -c "%g" /kong-prefix) if [ ! "$KONG_GID" = "$MOUNT_GID" ]; then # change KONG_GID to the ID of the folder owner group groupmod -g "$MOUNT_GID" --non-unique kong From ecf34fc074af125b8376943dd48160538dd6530b Mon Sep 17 00:00:00 2001 From: Wangchong Zhou Date: Tue, 5 Dec 2023 13:55:41 +0800 Subject: [PATCH 2/3] preserve behaviour on linux --- assets/docker-compose-linux-extend.yml | 6 ++++++ assets/docker-compose-nonlinux-extend.yml | 6 ++++++ assets/docker-compose.yml | 1 - pongo.sh | 12 ++++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 assets/docker-compose-linux-extend.yml create mode 100644 assets/docker-compose-nonlinux-extend.yml diff --git a/assets/docker-compose-linux-extend.yml b/assets/docker-compose-linux-extend.yml new file mode 100644 index 00000000..96659672 --- /dev/null +++ b/assets/docker-compose-linux-extend.yml @@ -0,0 +1,6 @@ +version: '3.5' + +services: + kong: + volumes: + - ${PONGO_WD}/servroot:/kong-prefix diff --git a/assets/docker-compose-nonlinux-extend.yml b/assets/docker-compose-nonlinux-extend.yml new file mode 100644 index 00000000..b50d7c50 --- /dev/null +++ b/assets/docker-compose-nonlinux-extend.yml @@ -0,0 +1,6 @@ +version: '3.5' + +services: + kong: + volumes: + - ${PONGO_WD}/servroot/logs:/kong-prefix/logs diff --git a/assets/docker-compose.yml b/assets/docker-compose.yml index 1adff576..afa84fad 100644 --- a/assets/docker-compose.yml +++ b/assets/docker-compose.yml @@ -170,4 +170,3 @@ services: - ${SERVICE_NETWORK_NAME}-kong.${SERVICE_NETWORK_NAME} volumes: - ${PONGO_WD}:/kong-plugin - - ${PONGO_WD}/servroot/logs:/kong-prefix/logs diff --git a/pongo.sh b/pongo.sh index 27625326..06f98665 100755 --- a/pongo.sh +++ b/pongo.sh @@ -25,6 +25,18 @@ function globals { DOCKER_FILE=${PONGO_DOCKER_FILE:-$LOCAL_PATH/assets/Dockerfile} DOCKER_COMPOSE_FILES="-f ${LOCAL_PATH}/assets/docker-compose.yml" + # macOS or WSL working on a drvfs mount doesn't support named pipes or Unix Domain Socket + if [ "$(uname -s)" == "Darwin" ] || ! (rm -f .pongo_test.sock; mkfifo .pongo_test.sock) 2>/dev/null; then + warn "Current directory doesn't support nix Domain Socket, thus only logs are" + warn "exposed onto host. To view other files under servroot, exec into the" + warn "pongo container and inspect \$KONG_PREFIX directory" + + rm -f .pongo_test.sock + DOCKER_COMPOSE_FILES="$DOCKER_COMPOSE_FILES -f ${LOCAL_PATH}/assets/docker-compose-nonlinux-extend.yml" + else + DOCKER_COMPOSE_FILES="$DOCKER_COMPOSE_FILES -f ${LOCAL_PATH}/assets/docker-compose-linux-extend.yml" + fi + IMAGE_BASE_NAME=kong-pongo-test # the path where the plugin source is located, as seen from Pongo (this script) From 89d163bf4ab2db84aaa0bbd0fcd2542a89c3a64e Mon Sep 17 00:00:00 2001 From: Wangchong Zhou Date: Wed, 6 Dec 2023 15:06:59 +0800 Subject: [PATCH 3/3] remove warn --- pongo.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pongo.sh b/pongo.sh index 06f98665..4a476b9c 100755 --- a/pongo.sh +++ b/pongo.sh @@ -27,10 +27,6 @@ function globals { DOCKER_COMPOSE_FILES="-f ${LOCAL_PATH}/assets/docker-compose.yml" # macOS or WSL working on a drvfs mount doesn't support named pipes or Unix Domain Socket if [ "$(uname -s)" == "Darwin" ] || ! (rm -f .pongo_test.sock; mkfifo .pongo_test.sock) 2>/dev/null; then - warn "Current directory doesn't support nix Domain Socket, thus only logs are" - warn "exposed onto host. To view other files under servroot, exec into the" - warn "pongo container and inspect \$KONG_PREFIX directory" - rm -f .pongo_test.sock DOCKER_COMPOSE_FILES="$DOCKER_COMPOSE_FILES -f ${LOCAL_PATH}/assets/docker-compose-nonlinux-extend.yml" else