psi-4ward / psitransfer

Simple open source self-hosted file sharing solution.
BSD 2-Clause "Simplified" License
1.46k stars 211 forks source link

Please update your Dockerfile to not use a hardcoded 1000 uid #258

Open electrofloat opened 1 year ago

electrofloat commented 1 year ago

Using id 1000 is very restrictive.

Would be a tons better if one could just give the uid/gid through env variables like what linuxserver.io does: https://docs.linuxserver.io/general/understanding-puid-and-pgid

psi-4ward commented 1 year ago

That's the standard of node:alpine. But feel free to make some suggestions

electrofloat commented 1 year ago

Yes. That's why I'm suggesting to do the same as linuxserver does. (https://github.com/linuxserver/docker-baseimage-alpine/blob/master/root/etc/s6-overlay/s6-rc.d/init-adduser/run) Use PUID and PGID env variables (which will be given by the user creating the container with --env), and either create a new user in your image with those ids for ex.:

groupmod -o -g "$PGID" abc
usermod -o -u "$PUID" abc
.
.
chown abc:abc /folder_used_by_your_app

or change the uid/gid of use node to the one provided in the env variables, for ex.:

usermod -u "$PUID" node
groupmod -g "$PGID" nodegroup
.
.
find / -group "$PGID" -exec chgrp -h nodegroup {} \;
find / -user "$PUID" -exec chown -h node {} \;

The last one of course assumes that the numbers given through env are available in the image itself, so probably the first one is safer to use.

psi-4ward commented 1 year ago

If you like prep a pr