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(mount) update permissions to ensure access #321

Merged
merged 2 commits into from
Sep 13, 2022
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
2 changes: 1 addition & 1 deletion assets/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ USER root
# But that means hardcoding and that doesn't play well with the nature of Pongo
# that should be independent of Kong versions.
RUN apk update \
&& apk add zip unzip make g++ py-pip jq git bsd-compat-headers m4 openssl-dev curl wget python3-dev \
&& apk add zip unzip make g++ py-pip jq git bsd-compat-headers m4 openssl-dev curl wget python3-dev shadow \
&& curl -k -s -S -L https://github.com/fullstorydev/grpcurl/releases/download/v1.7.0/grpcurl_1.7.0_linux_x86_64.tar.gz | tar xz -C /kong/bin \
&& pip install httpie \
; cd /kong \
Expand Down
25 changes: 25 additions & 0 deletions assets/pongo_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,31 @@ if [ -z "$KONG_TEST_LUA_SSL_TRUSTED_CERTIFICATE" ]; then
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).
# Since those permissions are controlled by the host, we update the 'kong' user
# inside the container to match the UID and GID.
hanshuebner marked this conversation as resolved.
Show resolved Hide resolved
if [ -d /kong-plugin ]; 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)
if [ ! "$KONG_GID" = "$MOUNT_GID" ]; then
# change KONG_GID to the ID of the folder owner group
groupmod -g "$MOUNT_GID" --non-unique kong
fi

if [ ! "$KONG_UID" = "$MOUNT_UID" ]; then
# change KONG_UID to the ID of the folder owner
usermod -u "$MOUNT_UID" -g "$MOUNT_GID" --non-unique kong
fi
unset KONG_UID
unset KONG_GID
unset MOUNT_UID
unset MOUNT_GID
fi


# perform any custom setup if specified
if [ -f /kong-plugin/.pongo/pongo-setup.sh ]; then
Expand Down