From 9bafc52626d005a667d0e10f4aaff12d6074f18e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 10 Mar 2024 23:52:14 +0100 Subject: [PATCH] do not recreate docker runner group and user --- docker/scripts/entry-point-dev.sh | 12 ++++++++---- docker/scripts/entry-point.sh | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/docker/scripts/entry-point-dev.sh b/docker/scripts/entry-point-dev.sh index 47ee3d9..1c63683 100755 --- a/docker/scripts/entry-point-dev.sh +++ b/docker/scripts/entry-point-dev.sh @@ -19,10 +19,14 @@ echo "Migrating DB..." ./mapg db:migrate echo "Set runner user based on owner of .env..." -USER_UID=$(stat -c "%u" .env) -USER_GID=$(stat -c "%g" .env) -groupadd --gid $USER_GID mapg -useradd --uid $USER_UID --gid $USER_GID mapg +if ! getent group mapg; then + USER_GID=$(stat -c "%g" .env) + groupadd --gid $USER_GID mapg +fi +if ! id -u mapg; then + USER_UID=$(stat -c "%u" .env) + useradd --uid $USER_UID --gid $USER_GID mapg +fi sed -i -e "s/^user = .*$/user = mapg/g" -e "s/^group = .*$/group = mapg/g" /etc/php/8.1/fpm/pool.d/www.conf set +e diff --git a/docker/scripts/entry-point.sh b/docker/scripts/entry-point.sh index cca2d24..d73ebcc 100755 --- a/docker/scripts/entry-point.sh +++ b/docker/scripts/entry-point.sh @@ -9,10 +9,14 @@ echo "Installing crontab..." /usr/bin/crontab docker/scripts/cron echo "Set runner user based on owner of .env..." -USER_UID=$(stat -c "%u" .env) -USER_GID=$(stat -c "%g" .env) -groupadd --gid $USER_GID mapg -useradd --uid $USER_UID --gid $USER_GID mapg +if ! getent group mapg; then + USER_GID=$(stat -c "%g" .env) + groupadd --gid $USER_GID mapg +fi +if ! id -u mapg; then + USER_UID=$(stat -c "%u" .env) + useradd --uid $USER_UID --gid $USER_GID mapg +fi chown mapg:mapg cache sed -i -e "s/^user = .*$/user = mapg/g" -e "s/^group = .*$/group = mapg/g" /etc/php/8.1/fpm/pool.d/www.conf