From df639957df77a87e968c85c8784b01a0aeb8d7b7 Mon Sep 17 00:00:00 2001 From: Orka Arnest CRUZE Date: Tue, 13 Feb 2024 16:00:27 +0100 Subject: [PATCH] build(docker): essai avec nginx unprivileged --- .docker/Dockerfile | 20 +++++++++++--------- .docker/nginx.conf | 12 ++++-------- .dockerignore | 1 - 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 1567114..0f43508 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -7,6 +7,7 @@ RUN apk add git WORKDIR /app COPY . . + RUN npm ci \ && npx @11ty/eleventy --pathprefix=/docs/ \ && npx pagefind --site _site/ --output-subdir \"_pagefind\" \ @@ -15,19 +16,20 @@ RUN npm ci \ #---------------------------------------------------------------------- # cartesgouvfr-documentation : Config d'un serveur statique avec nginx #---------------------------------------------------------------------- -FROM nginx:alpine -COPY --from=builder /app/_site /usr/share/nginx/html/docs/ +FROM nginxinc/nginx-unprivileged:alpine +COPY --from=builder /app/_site /usr/share/nginx/html/ +COPY --from=builder /app/_site/fr/index.html /usr/share/nginx/html/ COPY .docker/nginx.conf /etc/nginx/nginx.conf -WORKDIR /app +# WORKDIR /app -RUN chown -R nginx:nginx /app && chmod -R 755 /app \ - && chown -R nginx:nginx /var/cache/nginx \ - && chown -R nginx:nginx /var/log/nginx \ - && chown -R nginx:nginx /etc/nginx/conf.d +# RUN chown -R nginx:nginx /app && chmod -R 755 /app \ +# && chown -R nginx:nginx /var/cache/nginx \ +# && chown -R nginx:nginx /var/log/nginx \ +# && chown -R nginx:nginx /etc/nginx/conf.d -RUN touch /var/run/nginx.pid \ - && chown -R nginx:nginx /var/run/nginx.pid +# RUN touch /var/run/nginx.pid \ +# && chown -R nginx:nginx /var/run/nginx.pid EXPOSE 8082 diff --git a/.docker/nginx.conf b/.docker/nginx.conf index beec4c6..043c586 100644 --- a/.docker/nginx.conf +++ b/.docker/nginx.conf @@ -1,3 +1,4 @@ +pid /tmp/nginx.pid; worker_processes 1; events { @@ -26,21 +27,16 @@ http { index index.html index.htm; - # Redirect "/", "/docs" to "/fr" - location ~ ^(/|/docs(/)?)$ { - return 301 /docs/fr; - } - # Serve static files location / { root /usr/share/nginx/html; index index.html index.htm; - try_files $uri $uri/ /docs/404.html; + try_files $uri $uri/ /404.html; } # Handle 404 errors - error_page 404 /docs/404.html; - location = /docs/404.html { + error_page 404 /404.html; + location = /404.html { root /usr/share/nginx/html; internal; } diff --git a/.dockerignore b/.dockerignore index 036ffea..61acd64 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,5 @@ /.vscode /.github -/.docker/Dockerfile /node_modules/ /docs /_site