Refactor Dockerfile to improve user configuration and permissions
All checks were successful
Talks slides — image & chart / vars (push) Successful in 1s
Talks slides — image & chart / Helm chart (push) Successful in 8s
Talks slides — image & chart / Build container image (push) Successful in 24s

- 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:
Le Prévost-Corvellec Arnault
2026-04-08 22:12:44 +02:00
parent 4a5cbb950b
commit da748c2cae

View File

@@ -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}