Files
Talks/server/Dockerfile
Le Prévost-Corvellec Arnault 4a5cbb950b
Some checks failed
Talks slides — image & chart / vars (push) Successful in 2s
Talks slides — image & chart / Helm chart (push) Successful in 9s
Talks slides — image & chart / Build container image (push) Failing after 23s
Refactor Dockerfile to parameterize user and group IDs for enhanced flexibility
- Introduced ARG variables for UID and GID to allow dynamic user and group configuration.
- Updated ownership commands to utilize the new UID and GID parameters, improving compatibility with different environments.
- Maintained non-root user practices while ensuring proper permissions for Nginx and associated files.
2026-04-08 22:06:28 +02:00

40 lines
1.2 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# syntax=docker/dockerfile:1
# Même logique que limage upstream : UID/GID numériques, pas le nom « nginx ».
# https://github.com/nginxinc/docker-nginx-unprivileged/blob/main/stable/alpine/Dockerfile
FROM nginxinc/nginx-unprivileged:stable-alpine
ARG UID=101
ARG GID=101
USER root
RUN --mount=type=cache,target=/var/cache/apk \
apk add --no-cache git
WORKDIR /usr/share/nginx/html
ARG TALKS_REPO_URL=https://git.specificat.io/arnault/Talks.git
ARG TALKS_BRANCH=main
ARG TALKS_SPARSE_DIR=content
RUN find . -mindepth 1 -delete \
&& git clone --filter=blob:none --sparse --branch "${TALKS_BRANCH}" --single-branch "${TALKS_REPO_URL}" . \
&& git sparse-checkout init --cone \
&& git sparse-checkout set "${TALKS_SPARSE_DIR}"
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
COPY refresh.sh /refresh.sh
RUN chmod +x /refresh.sh \
&& chown -R "${UID}:${GID}" /usr/share/nginx/html /refresh.sh \
&& mkdir -p /home/nginx \
&& chown "${UID}:${GID}" /home/nginx \
&& su "${UID}" -s /bin/sh -c 'HOME=/home/nginx git config --global --add safe.directory /usr/share/nginx/html'
ENV HOME=/home/nginx
USER ${UID}
EXPOSE 8080
CMD sh -c "/refresh.sh & exec nginx -g 'daemon off;'"