From 9b9650d129fafb9104c10db50afd3d8df8aeb9fa Mon Sep 17 00:00:00 2001 From: Wangchong Zhou Date: Thu, 14 Dec 2023 16:47:34 +0800 Subject: [PATCH] fix(*) only mount logs directory and use a different prefix (#474) --- assets/docker-compose-linux-extend.yml | 6 ++++++ assets/docker-compose-nonlinux-extend.yml | 6 ++++++ assets/pongo_entrypoint.sh | 11 +++++------ pongo.sh | 7 +++++++ 4 files changed, 24 insertions(+), 6 deletions(-) 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/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 diff --git a/pongo.sh b/pongo.sh index c7dfdcb7..2268e8a7 100755 --- a/pongo.sh +++ b/pongo.sh @@ -98,6 +98,13 @@ function globals { export PONGO_PLATFORM="LINUX" fi + # macOS or WSL working on a drvfs mount doesn't support named pipes or Unix Domain Socket + if [ "$PONGO_PLATFORM" == "LINUX" ]; then + DOCKER_COMPOSE_FILES="$DOCKER_COMPOSE_FILES -f ${LOCAL_PATH}/assets/docker-compose-linux-extend.yml" + else + DOCKER_COMPOSE_FILES="$DOCKER_COMPOSE_FILES -f ${LOCAL_PATH}/assets/docker-compose-nonlinux-extend.yml" + fi + # when running CI do we have the required secrets available? (used for EE only) # secrets are unavailable for PR's from outside the organization (untrusted) # can be set to "true" or "false", defaults to the Travis-CI setting