From e1c3129e0adc21d13203e98d209626ae4057bd1d Mon Sep 17 00:00:00 2001 From: Orka Arnest CRUZE Date: Wed, 17 Jul 2024 14:06:58 +0200 Subject: [PATCH] build(docker): sub path /documentation --- .docker/Dockerfile | 6 +++--- .docker/nginx.conf | 8 ++++++-- compose.yml | 11 ++++++++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index c969590..3b039a5 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,7 +1,7 @@ #---------------------------------------------------------------------- # cartesgouvfr-documentation : Génération d'un build statique #---------------------------------------------------------------------- -FROM node:18-alpine as builder +FROM node:20-alpine AS builder RUN apk add git @@ -10,14 +10,14 @@ COPY . . # --pathprefix=/docs/ RUN npm ci \ - && npx @11ty/eleventy \ + && npx @11ty/eleventy --pathprefix=/documentation/ \ && npx pagefind --site _site/ --output-subdir \"_pagefind\" \ && rm -rf node_modules .git #---------------------------------------------------------------------- # cartesgouvfr-documentation : Config d'un serveur statique avec nginx #---------------------------------------------------------------------- -FROM nginxinc/nginx-unprivileged:alpine +FROM nginxinc/nginx-unprivileged:alpine-slim 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 diff --git a/.docker/nginx.conf b/.docker/nginx.conf index e1b3639..7f48dc2 100644 --- a/.docker/nginx.conf +++ b/.docker/nginx.conf @@ -34,8 +34,8 @@ http { index index.html index.htm; # Serve static files - location / { - root /usr/share/nginx/html; + location /documentation { + alias /usr/share/nginx/html; index index.html index.htm; try_files $uri $uri/ /404.html; } @@ -46,5 +46,9 @@ http { root /usr/share/nginx/html; internal; } + + location = / { + return 301 /documentation/; + } } } diff --git a/compose.yml b/compose.yml index e671e86..e674885 100644 --- a/compose.yml +++ b/compose.yml @@ -1,4 +1,6 @@ -version: "3.8" +networks: + web_dev: + external: true services: site: @@ -17,3 +19,10 @@ services: - http_proxy=${HTTP_PROXY} - https_proxy=${HTTPS_PROXY} restart: unless-stopped + networks: + - web_dev + labels: + - "traefik.enable=true" + - "traefik.http.routers.cartesgouvfr-documentation.rule=Host(`cartesgouvfr-documentation.docker.localhost`) && PathPrefix(`/documentation`)" + - "traefik.http.routers.cartesgouvfr-documentation.entrypoints=websecure" + - "traefik.http.services.cartesgouvfr-documentation.loadbalancer.server.port=8082"