-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Allow UID for git user in docker container to be specified via ENV variable #3520
Comments
cc @0rax |
Hi there, sorry for the delay. The thing being that the Git user is created a the creation of the container and not at runtime does not really allow us to make that configurable on a user to user basis. Nonetheless, this can still be possible by creating this user during container initialization (before Gogs is started). I totally understand the need for this kind of feature and will definitly try to implement that. I will keep you informed here, but as said, there is two way to do that:
GIT_UID=$(GIT_UID:-500) # default
adduser -H -D -g 'Gogs Git User' git -h /data/git -s /bin/bash -u ${GIT_UID} && passwd -u git Both options are correct, and I would prefer the creation of the user at runtime for ease of use (having to build the container yourself whenever there is an update upstream doesn't feel right when the project is already giving you a container). And this might not be that hard to implement as well, as we already change user at runtime to run gogs (running user is not set staticly in the Dockerfile). I have some other work to do on the container (upgrade to latest alpine and so on), I will definitly look at it in the mean time. |
Could this be implemented with the ability to set GID as well? Either way, ability to set UID/GUID would help avoid conflicts of user/group between host and container. Gogs is currently writing files as the An example of UID/GID setting from env variables, if it helps: |
Do need someone with expertise to propose a PR... |
Made a PR, hope it's ok. It uses Like others, I noticed the file ownership of my /var/gogs directory was 1000:1000 which mapped to my user (when I have a |
This is claimed to be fixed by merging #4776, please help test on |
Just one notice: Jenkins does this by a build argument: I do not know the pros and cons for this approach instead of environment variables, ... |
Both can be done. via build argument means you have to build the container yourself (which can be a nuisance as you'll have to manage changes and updates etc...) Using environment variable means you can use the official image and specify the ID's at runtime. The downside is that you can't run your container in I run my own image here: https://github.com/robertbeal/docker-gogs. The readme probably better explains the above. |
Description
It would be helpful for users who may use NFS or other shared storage for the gogs volume to have the UID of the git user specified in the add user command in build.sh. Basically, a variable such as GIT_UID, if set would invoke the add user command with the speceific user id, if not set, then don't run the command with a UID specified.Thanks
The text was updated successfully, but these errors were encountered: