Add new user with configurable UID and GID

This commit is contained in:
plantysnake 2022-11-17 14:45:19 +03:00
parent fd30cfe98b
commit 9b711ab109
4 changed files with 33 additions and 9 deletions

View file

@ -51,6 +51,10 @@ RUN chmod 644 /etc/logrotate.d/nginx-proxy-manager
RUN pip uninstall --yes setuptools \ RUN pip uninstall --yes setuptools \
&& pip install "setuptools==58.0.0" && pip install "setuptools==58.0.0"
RUN groupmod -g 1000 users \
&& useradd -u 911 -U -d /data -s /bin/false abc \
&& usermod -G users abc
VOLUME [ "/data", "/etc/letsencrypt" ] VOLUME [ "/data", "/etc/letsencrypt" ]
ENTRYPOINT [ "/init" ] ENTRYPOINT [ "/init" ]

View file

@ -1,7 +0,0 @@
#!/usr/bin/with-contenv bash
set -e
mkdir -p /data/logs
echo "Changing ownership of /data/logs to $(id -u):$(id -g)"
chown -R "$(id -u):$(id -g)" /data/logs

View file

@ -0,0 +1,25 @@
#!/usr/bin/with-contenv bash
set -e
PUID=${PUID:-911}
PGID=${PGID:-911}
groupmod -o -g "$PGID" abc
usermod -o -u "$PUID" abc
echo '
-------------------------------------
GID/UID
-------------------------------------'
echo "
User uid: $(id -u abc)
User gid: $(id -g abc)
-------------------------------------
"
mkdir -p /data/logs
echo "Changing ownership of /data to abc:abc"
chown -R abc:abc /data
echo "Changing ownership of /etc/letsencrypt to abc:abc"
chown -R abc:abc /etc/letsencrypt

View file

@ -1,5 +1,6 @@
/data/logs/*_access.log /data/logs/*/access.log { /data/logs/*_access.log /data/logs/*/access.log {
create 0644 root root su root root
create 0644 abc abc
weekly weekly
rotate 4 rotate 4
missingok missingok
@ -12,7 +13,8 @@
} }
/data/logs/*_error.log /data/logs/*/error.log { /data/logs/*_error.log /data/logs/*/error.log {
create 0644 root root su root root
create 0644 abc abc
weekly weekly
rotate 10 rotate 10
missingok missingok