Skip to content

Commit

Permalink
build(docker): sub path /documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ocruze committed Jul 17, 2024
1 parent 88c19e5 commit e1c3129
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions .docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -46,5 +46,9 @@ http {
root /usr/share/nginx/html;
internal;
}

location = / {
return 301 /documentation/;
}
}
}
11 changes: 10 additions & 1 deletion compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
version: "3.8"
networks:
web_dev:
external: true

services:
site:
Expand All @@ -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"

0 comments on commit e1c3129

Please sign in to comment.