From b3964df9b2afa5a66dfd1018def8b6abfc27590e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=27=C3=A9lectron=20rare?= <108685187+electron-rare@users.noreply.github.com> Date: Thu, 9 Jul 2026 12:22:42 +0200 Subject: [PATCH] build: add nginx docker image and compose Dockerfile implements multi-stage build: node:22-alpine for build stage, nginx:1.27-alpine for production runtime. nginx.conf provides SPA routing with gzip compression and cache headers. docker-compose.yml prepared for Tower Traefik integration with external network and Host route. All files match specification verbatim. --- .dockerignore | 5 +++++ Dockerfile | 10 ++++++++++ docker-compose.yml | 17 +++++++++++++++++ nginx.conf | 23 +++++++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 nginx.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..39a3112 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +node_modules +dist +test-results +playwright-report +.git diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d8df271 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM node:22-alpine AS build +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm ci +COPY . . +RUN npm run build + +FROM nginx:1.27-alpine +COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=build /app/dist /usr/share/nginx/html diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3fe278a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +services: + web: + build: . + container_name: clement-saillant-cc + restart: unless-stopped + networks: + - traefik + labels: + - traefik.enable=true + - traefik.http.routers.clement.rule=Host(`clement.saillant.cc`) + - traefik.http.routers.clement.entrypoints=websecure + - traefik.http.routers.clement.tls.certresolver=letsencrypt + - traefik.http.services.clement.loadbalancer.server.port=80 + +networks: + traefik: + external: true diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..5dbb210 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,23 @@ +server { + listen 80; + server_name _; + root /usr/share/nginx/html; + index index.html; + + gzip on; + gzip_types text/css application/javascript application/wasm image/svg+xml; + + add_header X-Content-Type-Options nosniff; + add_header Referrer-Policy no-referrer-when-downgrade; + + location /assets/ { + add_header Cache-Control "public, max-age=31536000, immutable"; + } + location /music/ { + add_header Cache-Control "public, max-age=86400"; + } + location / { + try_files $uri $uri/ /index.html; + add_header Cache-Control "no-cache"; + } +}