From f3b05961aae82fa3e19c47f03c78974cf793fda3 Mon Sep 17 00:00:00 2001 From: eightpigs Date: Tue, 7 Apr 2020 15:12:08 +0800 Subject: docker: fix the bug of using root account to create `/data/*` directory (#6068) * Fix the bug of using root account to create /data directory * Fix the bug that sshkey cannot be added in the container and remove unnecessary chown. --- docker/start.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'docker/start.sh') diff --git a/docker/start.sh b/docker/start.sh index 9f9d40e9..15f82609 100755 --- a/docker/start.sh +++ b/docker/start.sh @@ -33,16 +33,17 @@ create_volume_subfolder() { # Create VOLUME subfolder for f in /data/gogs/data /data/gogs/conf /data/gogs/log /data/git /data/ssh; do if ! test -d $f; then - mkdir -p $f + exec gosu $USER mkdir -p $f fi done } setids() { + export USER=git PUID=${PUID:-1000} PGID=${PGID:-1000} - groupmod -o -g "$PGID" git - usermod -o -u "$PUID" git + groupmod -o -g "$PGID" $USER + usermod -o -u "$PUID" $USER } setids -- cgit v1.2.3