Allow setting www-data UID and GID id at runtime
This commit is contained in:
parent
7151ceadc3
commit
a24ecbd1b4
@ -2,9 +2,9 @@ FROM nginx:alpine
|
|||||||
|
|
||||||
ENV PHP_FPM="php:9000"
|
ENV PHP_FPM="php:9000"
|
||||||
|
|
||||||
RUN deluser xfs && \
|
ENV WWW_DATA_UID=33 WWW_DATA_GID=33
|
||||||
delgroup www-data && \
|
|
||||||
adduser -DH -h /home/www-data -s /sbin/nologin -u 33 www-data
|
RUN apk add --no-cache shadow
|
||||||
|
|
||||||
RUN find /etc/nginx -type f -not -name 'mime.types' -not -name 'fastcgi_params' -delete && \
|
RUN find /etc/nginx -type f -not -name 'mime.types' -not -name 'fastcgi_params' -delete && \
|
||||||
rm -rf conf.d modules
|
rm -rf conf.d modules
|
||||||
|
|||||||
@ -1,5 +1,24 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ -n "$(getent passwd "$WWW_DATA_UID")" ]
|
||||||
|
then
|
||||||
|
USERNAME=$(getent passwd "$WWW_DATA_UID" | cut -d: -f1)
|
||||||
|
echo "Deleting user $USERNAME which already uses UID $WWW_DATA_UID"
|
||||||
|
deluser "$USERNAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$(getent group "$WWW_DATA_GID")" ]
|
||||||
|
then
|
||||||
|
GROUPNAME=$(getent passwd "$WWW_DATA_GID" | cut -d: -f1)
|
||||||
|
echo "Deleting group $GROUPNAME which already uses GID $WWW_DATA_GID"
|
||||||
|
delgroup "$GROUPNAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# for some reason, a www-data group exists by default but a www-data user doesn't
|
||||||
|
echo "Adding www-data user with UID $WWW_DATA_UID and setting www-data GID to $WWW_DATA_GID"
|
||||||
|
groupmod -g "$WWW_DATA_GID" www-data
|
||||||
|
adduser -D -G www-data -u "$WWW_DATA_UID" www-data
|
||||||
|
|
||||||
cat > /etc/nginx/php.conf << EOL
|
cat > /etc/nginx/php.conf << EOL
|
||||||
upstream php-handler {
|
upstream php-handler {
|
||||||
server ${PHP_FPM};
|
server ${PHP_FPM};
|
||||||
|
|||||||
@ -5,12 +5,9 @@ ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/do
|
|||||||
RUN chmod +x /usr/local/bin/install-php-extensions && \
|
RUN chmod +x /usr/local/bin/install-php-extensions && \
|
||||||
install-php-extensions gd pdo_mysql mysqli zip exif
|
install-php-extensions gd pdo_mysql mysqli zip exif
|
||||||
|
|
||||||
# Set www-data user and group to id 33 which is standard in Debian
|
ENV WWW_DATA_UID=33 WWW_DATA_GID=33
|
||||||
RUN deluser xfs && \
|
|
||||||
apk add --no-cache shadow && \
|
RUN apk add --no-cache shadow
|
||||||
usermod -u 33 www-data && \
|
|
||||||
groupmod -g 33 www-data && \
|
|
||||||
apk del shadow
|
|
||||||
|
|
||||||
RUN { \
|
RUN { \
|
||||||
echo "upload_max_filesize = 512M"; \
|
echo "upload_max_filesize = 512M"; \
|
||||||
|
|||||||
@ -1,6 +1,24 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
if [ -n "$(getent passwd "$WWW_DATA_UID")" ]
|
||||||
|
then
|
||||||
|
USERNAME=$(getent passwd "$WWW_DATA_UID" | cut -d: -f1)
|
||||||
|
echo "Deleting user $USERNAME which already uses UID $WWW_DATA_UID"
|
||||||
|
deluser "$USERNAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$(getent group "$WWW_DATA_GID")" ]
|
||||||
|
then
|
||||||
|
GROUPNAME=$(getent passwd "$WWW_DATA_GID" | cut -d: -f1)
|
||||||
|
echo "Deleting group $GROUPNAME which already uses GID $WWW_DATA_GID"
|
||||||
|
delgroup "$GROUPNAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Setting www-data uid:gid to $WWW_DATA_UID:$WWW_DATA_GID"
|
||||||
|
usermod -u "$WWW_DATA_UID" www-data
|
||||||
|
groupmod -g "$WWW_DATA_GID" www-data
|
||||||
|
|
||||||
if [ -n "$(ls -A /data 2>/dev/null)" ]
|
if [ -n "$(ls -A /data 2>/dev/null)" ]
|
||||||
then
|
then
|
||||||
echo "Data directory contains files, not downloading NamelessMC"
|
echo "Data directory contains files, not downloading NamelessMC"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user