Skip to content

Bugfix: change default git user to 1010:1010 and make git user more configurable #29270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions Dockerfile.rootless
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions docs/content/installation/with-docker-rootless.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions docs/content/installation/with-docker-rootless.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
```

> 如果未为卷设置正确的权限,容器可能无法启动。
Expand Down
24 changes: 12 additions & 12 deletions docs/content/installation/with-docker.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
24 changes: 12 additions & 12 deletions docs/content/installation/with-docker.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 匹配(对于命名卷,则不需要这样做)。

## 自定义

Expand Down Expand Up @@ -319,8 +319,8 @@ services:

```bash
environment:
- USER_UID=1000
- USER_GID=1000
- USER_UID=1010
- USER_GID=1010
```

接下来将主机的 `/home/git/.ssh` 装入容器。否则,SSH 身份验证将无法在容器内运行。
Expand Down