Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(*) only mount logs directory and use a different prefix #474

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions assets/docker-compose-linux-extend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: '3.5'

services:
kong:
volumes:
- ${PONGO_WD}/servroot:/kong-prefix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fffonion mind having a look? I think we can remove the one from the main docker compose file no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually no conflict here, the mount from main file is for getting in the plugin code for test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pwd -> /kong-plugin
pwd/servroot -> /kong-prefix
we can't do
pwd/servroot -> /kong-plugin/servroot
anymore because that will be a bind mount on host and not supported on macos

6 changes: 6 additions & 0 deletions assets/docker-compose-nonlinux-extend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: '3.5'

services:
kong:
volumes:
- ${PONGO_WD}/servroot/logs:/kong-prefix/logs
11 changes: 5 additions & 6 deletions assets/pongo_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions pongo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ 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
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)
Expand Down
Loading