From 6f12e54f9c2b4572787de89be7bb92caa12c3e8e Mon Sep 17 00:00:00 2001 From: rohhie Date: Mon, 1 May 2023 18:49:06 +0900 Subject: [PATCH] Fix UID/GID handling in user git --- 01-setup.sh | 6 +++++- docker/docker-compose.yml | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/01-setup.sh b/01-setup.sh index 3781497..9f803bd 100755 --- a/01-setup.sh +++ b/01-setup.sh @@ -129,13 +129,17 @@ secho 5 echo "================================================" echo " ユーザーgitの作成" echo "================================================" -sudo useradd -u 1997 -m git +sudo useradd -m git if [ $? -ne 0 ]; then echo "処理を中止します" exit fi +echo "=== UID/GIDの書き換え" +sed -i "s/\(- USER_UID=\)[[:digit:]]\+/\1$(id -u git)/" docker/docker-compose.yml +sed -i "s/\(- USER_GID=\)[[:digit:]]\+/\1$(id -g git)/" docker/docker-compose.yml + echo "=== gitの証明書の作成" sudo -u git ssh-keygen -t rsa -b 4096 -C "Gitea Host Key" -f /home/git/.ssh/id_rsa sudo -u git cp /home/git/.ssh/id_rsa.pub /home/git/.ssh/authorized_keys diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index f5ad735..d7703d0 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -45,8 +45,8 @@ services: image: custom/gitea container_name: gitea environment: - - USER_UID=1997 - - USER_GID=1997 + - USER_UID=1000 + - USER_GID=1000 - GITEA__database__DB_TYPE=mysql - GITEA__database__HOST=db:3306 - GITEA__database__NAME=gitea