Refactor Dockerfile to improve user configuration and permissions
- Removed the creation of a home directory for the nginx user, simplifying the setup for a stateless image. - Updated git configuration to use a temporary home directory, enhancing compatibility with non-root user practices. - Adjusted ownership of the temporary git configuration file to align with UID and GID parameters.
This commit is contained in:
@@ -24,13 +24,13 @@ RUN find . -mindepth 1 -delete \
|
|||||||
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
|
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||||
COPY refresh.sh /refresh.sh
|
COPY refresh.sh /refresh.sh
|
||||||
|
|
||||||
|
# Pas de « su 101 » : git config en root puis chown. HOME=/tmp : pas de /home artificiel dans une image stateless.
|
||||||
RUN chmod +x /refresh.sh \
|
RUN chmod +x /refresh.sh \
|
||||||
&& chown -R "${UID}:${GID}" /usr/share/nginx/html /refresh.sh \
|
&& chown -R "${UID}:${GID}" /usr/share/nginx/html /refresh.sh \
|
||||||
&& mkdir -p /home/nginx \
|
&& HOME=/tmp git config --global --add safe.directory /usr/share/nginx/html \
|
||||||
&& chown "${UID}:${GID}" /home/nginx \
|
&& chown "${UID}:${GID}" /tmp/.gitconfig
|
||||||
&& su "${UID}" -s /bin/sh -c 'HOME=/home/nginx git config --global --add safe.directory /usr/share/nginx/html'
|
|
||||||
|
|
||||||
ENV HOME=/home/nginx
|
ENV HOME=/tmp
|
||||||
|
|
||||||
USER ${UID}
|
USER ${UID}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user