From 2f1742510429bd50654b1ccb7d3a8d9d36106033 Mon Sep 17 00:00:00 2001 From: dachary Date: Mon, 29 Nov 2021 05:55:33 +0800 Subject: [PATCH] allow override of gid/uid from the build command (#11) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is useful when running from a development environment with a setup identical to the CI. Signed-off-by: Loïc Dachary Reviewed-on: https://gitea.com/gitea/test-env/pulls/11 Reviewed-by: Andrew Thornton Reviewed-by: techknowlogick Co-authored-by: dachary Co-committed-by: dachary --- Dockerfile | 8 +++++--- README.md | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8a83bff..4b4d6a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,15 @@ FROM golang:1.17-buster +ARG GITEA_ID=1000 +ARG GITEA_GID=1000 RUN addgroup \ - --gid 1000 \ + --gid $GITEA_GID \ gitea && \ adduser \ --gecos '' \ --shell /bin/bash \ - --uid 1000 \ - --gid 1000 \ + --uid $GITEA_ID \ + --gid $GITEA_GID \ gitea # upgrade git to v2.33.0 diff --git a/README.md b/README.md index 7305604..8b6e302 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,9 @@ A docker image for Gitea ci test - upgrade git to v2.33.0 - install git-lfs - install [golangci-lint](https://github.com/golangci/golangci-lint) v1.43.0 + +# development environment build + +In order to run from within a development environment at the root of the gitea repository with a command such as `docker run --volume $(pwd):/drone/src --workdir /drone/src --user gitea mytestenv ...` the id of the gitea user must match the id of the development environment. + +- docker build --tag mytestenv --build-arg GITEA_ID=$(id -u) --build-arg GITEA_GID=$(id -g) .