commit 4c4364ae53a19b90d8b3b6a533f23f093291ed5b
parent e39e182093b6971ac11d9b33d40c4131d36d4b6a
Author: Matthias Jaros <jaros@mailbox.org>
Date: Mon, 27 Oct 2025 11:57:39 +0100
Added handling of gid for git user also
Diffstat:
4 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/Dockerfile b/Dockerfile
@@ -3,6 +3,7 @@ RUN apk add --no-cache openssh-server fish git sudo
# default uid for git user who has access to all repos
ENV GIT_UID=1000
+ENV GIT_GID=1000
# Modified ssh conf with disabled root login and no password authentication
COPY src/ssh.conf /etc/ssh/sshd_config.d/
diff --git a/Jenkinsfile b/Jenkinsfile
@@ -37,7 +37,7 @@ pipeline {
env.GIT_SHA = sh(script: "git rev-parse --short HEAD", returnStdout: true).trim()
// compose image name + tags
- env.GROUP_ID = "com.it-jaros.git"
+ env.GROUP_ID = "com.it-jaros.git"
env.IMAGE_NAME = "${REGISTRY}/${GROUP_ID}"
echo "sha=${env.GIT_SHA}"
echo "image=${env.IMAGE_NAME}"
diff --git a/docker-compose.yml b/docker-compose.yml
@@ -9,7 +9,8 @@ services:
restart: no
environment:
# Note: Variable names cannot have - inside but the values can!
- - GIT_UID=1000 # uid of the user that has access to all repos
+ - GIT_UID=1000 # uid/gid of the user that has access to all repos
+ - GIT_GID=1000
# Users in form of USER_<some chars>=<username>:<ssh-key>
- USER_user1=user1:ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBPsl91WPAT8aWwZ6y5WAfXU9PoHzxJ3YG9uFgSmlGQr2HwV+gL/XaTBJ4Brj+pa+R7tfYEBMi+7Navx/ZsEmr9E= mj@xps15
- USER_user2=user2:ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBPsl91WPAT8aWwZ6y5WAfXU9PoHzxJ3YG9uFgSmlGQr2HwV+gL/XaTBJ4Brj+pa+R7tfYEBMi+7Navx/ZsEmr9E= mj@xps15
diff --git a/src/init b/src/init
@@ -16,7 +16,7 @@ function checkUser
return $status
end
-function createUser
+function setupUser
set -l userConfig (string split ':' $argv[1])
set -l user $userConfig[1]
set -l key $userConfig[2]
@@ -47,7 +47,8 @@ function setupGitUser
echo "Setting up git user"
# git user has read/write access to all repos, set git-shell
# and no password login allowed -> no ssh login possible
- adduser git -u $GIT_UID -D --shell "/usr/bin/git-shell"
+ addgroup -g $GIT_GID git
+ adduser git -u $GIT_UID -G git -D --shell "/usr/bin/git-shell"
# group that is allowed to sudo
addgroup $_GIT_SUDO_GROUP
end
@@ -157,7 +158,7 @@ end
# Setup users
setupGitUser
for userConfig in $users
- createUser "$userConfig"
+ setupUser "$userConfig"
end
# Setup repos