Fix #14: allow for UID/GID specification via PUID/PGID env variables - #26
Fix #14: allow for UID/GID specification via PUID/PGID env variables#26flexd wants to merge 1 commit into
Conversation
|
@duckfullstop Mentioning you in case you didn't see this :) |
|
Sorry for the horrendous delay here, life happened 馃檱 I'm planning on reviewing this in the coming days when I'm a bit more awake, but my personal preference is to make the container run properly using an external UID/GID override (eg I'm not averse to additionally merging this to provide a simple envvar based way of handling the issue, but is there a strong argument to do so over simply being tolerant to any uid/gid combination running? (Update: I have tested with the |
duckfullstop
left a comment
There was a problem hiding this comment.
Code itself LGTM though.
|
docker-compose files usually use environment variables for UID/PID as far as I know. What this PR does differently over just overriding UID/GID is that the openttd user has it's UID/GID changed to the specified one. We no longer need to chown any of those files or change the permissions to be accessible by all |
Hi there!
I made it so you can specify PUID/PGID when starting this container, fixing #14.
TLDR; Add the openttd user as normal, but run a new entrypoint as root which changes the uid/gid on "openttd" to the specified ones and then drops privileges to that user and runs the original entrypoint
I took some inspiration from how LinuxServers do it [1] , and also this Dockerfile/entrypoint where gosu was used https://github.com/sudo-bmitch/jenkins-docker/tree/main
Using gosu seems to be common practice [3]
[1] https://github.com/linuxserver/docker-baseimage-ubuntu/blob/focal/root/etc/s6-overlay/s6-rc.d/init-adduser/run
[2] (https://github.com/tianon/gosu?tab=readme-ov-file#gosu
[3] https://denibertovic.com/posts/handling-permissions-with-docker-volumes/