From 034a5d3449bd68a62593269493a3f052554fe982 Mon Sep 17 00:00:00 2001 From: sb Date: Mon, 19 Feb 2024 19:58:05 +0000 Subject: [PATCH 1/3] bugfix: make git user configurable --- Dockerfile | 9 +++++++-- Dockerfile.rootless | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index b647c0cd590e9..cdc8635f56ff2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,11 @@ ARG TAGS="sqlite sqlite_unlock_notify" ENV TAGS "bindata timetzdata $TAGS" ARG CGO_EXTRA_CFLAGS +ARG GIT_UID +ARG GIT_GID +ENV GIT_GID_ENV=${GIT_GID} +ENV GIT_UID_ENV=${GIT_UID} + # Build deps RUN apk --no-cache add \ build-base \ @@ -61,13 +66,13 @@ RUN apk --no-cache add \ && rm -rf /var/cache/apk/* RUN addgroup \ - -S -g 1000 \ + -S -g ${GIT_GID_ENV:-1010} \ git && \ adduser \ -S -H -D \ -h /data/git \ -s /bin/bash \ - -u 1000 \ + -u ${GIT_UID_ENV:-1010} \ -G git \ git && \ echo "git:*" | chpasswd -e diff --git a/Dockerfile.rootless b/Dockerfile.rootless index dd7da97278311..62947335d9597 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -9,6 +9,11 @@ ARG TAGS="sqlite sqlite_unlock_notify" ENV TAGS "bindata timetzdata $TAGS" ARG CGO_EXTRA_CFLAGS +ARG GIT_UID +ARG GIT_GID +ENV GIT_GID_ENV=${GIT_GID} +ENV GIT_UID_ENV=${GIT_UID} + #Build deps RUN apk --no-cache add \ build-base \ @@ -55,13 +60,13 @@ RUN apk --no-cache add \ && rm -rf /var/cache/apk/* RUN addgroup \ - -S -g 1000 \ + -S -g ${GIT_GID_ENV:-1010} \ git && \ adduser \ -S -H -D \ -h /var/lib/gitea/git \ -s /bin/bash \ - -u 1000 \ + -u ${GIT_UID_ENV:-1010} \ -G git \ git From 572e14fcff60955ecb608905a6d4aeaed98c546e Mon Sep 17 00:00:00 2001 From: sb Date: Mon, 19 Feb 2024 20:13:08 +0000 Subject: [PATCH 2/3] updating install documentation --- .../with-docker-rootless.en-us.md | 4 ++-- .../content/installation/with-docker.en-us.md | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/content/installation/with-docker-rootless.en-us.md b/docs/content/installation/with-docker-rootless.en-us.md index 10f121221727c..86574974aea1b 100644 --- a/docs/content/installation/with-docker-rootless.en-us.md +++ b/docs/content/installation/with-docker-rootless.en-us.md @@ -59,10 +59,10 @@ services: - "2222:2222" ``` -Note that the volume should be owned by the user/group with the UID/GID specified in the config file. By default Gitea in docker will use uid:1000 gid:1000. If needed you can set ownership on those folders with the command: +Note that the volume should be owned by the user/group with the UID/GID specified in the config file. By default Gitea in docker will use uid:1010 gid:1010. If needed you can set ownership on those folders with the command: ```sh -sudo chown 1000:1000 config/ data/ +sudo chown 1010:1010 config/ data/ ``` > If you don't give the volume correct permissions, the container may not start. diff --git a/docs/content/installation/with-docker.en-us.md b/docs/content/installation/with-docker.en-us.md index e67f5bccb2a41..ec43430fbf97d 100644 --- a/docs/content/installation/with-docker.en-us.md +++ b/docs/content/installation/with-docker.en-us.md @@ -46,8 +46,8 @@ services: image: gitea/gitea:@version@ container_name: gitea environment: - - USER_UID=1000 - - USER_GID=1000 + - USER_UID=1010 + - USER_GID=1010 restart: always networks: - gitea @@ -78,8 +78,8 @@ services: image: gitea/gitea:@version@ container_name: gitea environment: - - USER_UID=1000 - - USER_GID=1000 + - USER_UID=1010 + - USER_GID=1010 restart: always networks: - gitea @@ -113,8 +113,8 @@ services: image: gitea/gitea:@version@ container_name: gitea environment: - - USER_UID=1000 - - USER_GID=1000 + - USER_UID=1010 + - USER_GID=1010 + - GITEA__database__DB_TYPE=mysql + - GITEA__database__HOST=db:3306 + - GITEA__database__NAME=gitea @@ -164,8 +164,8 @@ services: image: gitea/gitea:@version@ container_name: gitea environment: - - USER_UID=1000 - - USER_GID=1000 + - USER_UID=1010 + - USER_GID=1010 + - GITEA__database__DB_TYPE=postgres + - GITEA__database__HOST=db:5432 + - GITEA__database__NAME=gitea @@ -256,8 +256,8 @@ documented above, please note that `db` must be used as the database hostname. ## Configure the user inside Gitea using environment variables - `USER`: **git**: The username of the user that runs Gitea within the container. -- `USER_UID`: **1000**: The UID (Unix user ID) of the user that runs Gitea within the container. Match this to the UID of the owner of the `/data` volume if using host volumes (this is not necessary with named volumes). -- `USER_GID`: **1000**: The GID (Unix group ID) of the user that runs Gitea within the container. Match this to the GID of the owner of the `/data` volume if using host volumes (this is not necessary with named volumes). +- `USER_UID`: **1010**: The UID (Unix user ID) of the user that runs Gitea within the container. Match this to the UID of the owner of the `/data` volume if using host volumes (this is not necessary with named volumes). +- `USER_GID`: **1010**: The GID (Unix group ID) of the user that runs Gitea within the container. Match this to the GID of the owner of the `/data` volume if using host volumes (this is not necessary with named volumes). ## Customization @@ -363,8 +363,8 @@ In this option, the idea is that the host simply uses the `authorized_keys` that ```yaml environment: - - USER_UID=1000 - - USER_GID=1000 + - USER_UID=1010 + - USER_GID=1010 ``` - Mount `/home/git/.ssh` of the host into the container. This ensures that the `authorized_keys` file is shared between the host `git` user and the container `git` user otherwise the SSH authentication cannot work inside the container. From 4c01fc81431ae5e588a55bc5ac0dc8a19346676a Mon Sep 17 00:00:00 2001 From: sb Date: Mon, 19 Feb 2024 20:15:18 +0000 Subject: [PATCH 3/3] updated the chinese translation documents also. --- .../with-docker-rootless.zh-cn.md | 4 ++-- .../content/installation/with-docker.zh-cn.md | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/content/installation/with-docker-rootless.zh-cn.md b/docs/content/installation/with-docker-rootless.zh-cn.md index 70bc32dc12a29..9bd68aeda4473 100644 --- a/docs/content/installation/with-docker-rootless.zh-cn.md +++ b/docs/content/installation/with-docker-rootless.zh-cn.md @@ -54,10 +54,10 @@ services: - "2222:2222" ``` -请注意,卷应由在配置文件中指定的UID/GID的用户/组所有。默认情况下,Docker中的Gitea将使用uid:1000 gid:1000。如果需要,您可以使用以下命令设置这些文件夹的所有权: +请注意,卷应由在配置文件中指定的UID/GID的用户/组所有。默认情况下,Docker中的Gitea将使用uid:1010 gid:1010。如果需要,您可以使用以下命令设置这些文件夹的所有权: ```sh -sudo chown 1000:1000 config/ data/ +sudo chown 1010:1010 config/ data/ ``` > 如果未为卷设置正确的权限,容器可能无法启动。 diff --git a/docs/content/installation/with-docker.zh-cn.md b/docs/content/installation/with-docker.zh-cn.md index fcaff1c1197f1..f1ba3c420c23d 100644 --- a/docs/content/installation/with-docker.zh-cn.md +++ b/docs/content/installation/with-docker.zh-cn.md @@ -37,8 +37,8 @@ services: image: gitea/gitea:@version@ container_name: gitea environment: - - USER_UID=1000 - - USER_GID=1000 + - USER_UID=1010 + - USER_GID=1010 restart: always networks: - gitea @@ -67,8 +67,8 @@ services: image: gitea/gitea:@version@ container_name: gitea environment: - - USER_UID=1000 - - USER_GID=1000 + - USER_UID=1010 + - USER_GID=1010 restart: always networks: - gitea @@ -101,8 +101,8 @@ services: image: gitea/gitea:@version@ container_name: gitea environment: - - USER_UID=1000 - - USER_GID=1000 + - USER_UID=1010 + - USER_GID=1010 + - GITEA__database__DB_TYPE=mysql + - GITEA__database__HOST=db:3306 + - GITEA__database__NAME=gitea @@ -151,8 +151,8 @@ services: image: gitea/gitea:@version@ container_name: gitea environment: - - USER_UID=1000 - - USER_GID=1000 + - USER_UID=1010 + - USER_GID=1010 + - GITEA__database__DB_TYPE=postgres + - GITEA__database__HOST=db:5432 + - GITEA__database__NAME=gitea @@ -255,8 +255,8 @@ MySQL 或 PostgreSQL 容器将需要分别创建。 - `SECRET_KEY`:**""** :全局密钥。这应该更改。如果它具有一个值并且 `INSTALL_LOCK` 为空,则 `INSTALL_LOCK` 将自动设置为 `true`。 - `DISABLE_REGISTRATION`:**false**:禁用注册,之后只有管理员才能为用户创建帐户。 - `REQUIRE_SIGNIN_VIEW`:**false**:启用此选项可强制用户登录以查看任何页面。 -- `USER_UID`:**1000**:在容器内运行 Gitea 的用户的 UID(Unix 用户 ID)。如果使用主机卷,则将其与 `/data` 卷的所有者的 UID 匹配(对于命名卷,则不需要这样做)。 -- `USER_GID`:**1000**:在容器内运行 Gitea 的用户的 GID(Unix 组 ID)。如果使用主机卷,则将其与 `/data` 卷的所有者的 GID 匹配(对于命名卷,则不需要这样做)。 +- `USER_UID`:**1010**:在容器内运行 Gitea 的用户的 UID(Unix 用户 ID)。如果使用主机卷,则将其与 `/data` 卷的所有者的 UID 匹配(对于命名卷,则不需要这样做)。 +- `USER_GID`:**1010**:在容器内运行 Gitea 的用户的 GID(Unix 组 ID)。如果使用主机卷,则将其与 `/data` 卷的所有者的 GID 匹配(对于命名卷,则不需要这样做)。 ## 自定义 @@ -319,8 +319,8 @@ services: ```bash environment: - - USER_UID=1000 - - USER_GID=1000 + - USER_UID=1010 + - USER_GID=1010 ``` 接下来将主机的 `/home/git/.ssh` 装入容器。否则,SSH 身份验证将无法在容器内运行。