From 530fed2f7b33bd3c359377f5b6012fa3a04521cc Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 10:17:56 +0100 Subject: [PATCH 01/12] chore(git): ignore .vscode folder --- .gitignore | 7 +++++++ .vscode/extensions.json | 4 ---- .vscode/launch.json | 11 ----------- 3 files changed, 7 insertions(+), 15 deletions(-) delete mode 100644 .vscode/extensions.json delete mode 100644 .vscode/launch.json diff --git a/.gitignore b/.gitignore index 16d54bb..e4866ae 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ dist/ # dependencies node_modules/ +.pnpm-store/ # logs npm-debug.log* @@ -22,3 +23,9 @@ pnpm-debug.log* # jetbrains setting folder .idea/ + +# vscode +.vscode/ + +# Lighthouse CI reports +.lighthouseci/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 56f043d..0000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "recommendations": ["astro-build.astro-vscode", "unifiedjs.vscode-mdx"], - "unwantedRecommendations": [] -} diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index d642209..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "command": "./node_modules/.bin/astro dev", - "name": "Development server", - "request": "launch", - "type": "node-terminal" - } - ] -} -- 2.49.1 From c270b631dd4364d8fbedabc754c241cbd62c6e14 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 10:23:42 +0100 Subject: [PATCH 02/12] ci(lighthouse): add local lighthouse audit --- .lighthouserc.cjs | 22 ++++++++++++++++++++++ local-lighthouse.sh | 14 ++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .lighthouserc.cjs create mode 100755 local-lighthouse.sh diff --git a/.lighthouserc.cjs b/.lighthouserc.cjs new file mode 100644 index 0000000..015a3fa --- /dev/null +++ b/.lighthouserc.cjs @@ -0,0 +1,22 @@ +module.exports = { + ci: { + collect: { + staticDistDir: '/app/dist', + settings: { + chromeFlags: '--no-sandbox --disable-setuid-sandbox --headless=new --disable-gpu --disable-dev-shm-usage', + }, + numberOfRuns: 1 + }, + assert: { + assertions: { + 'categories:performance': ['error', {minScore: 0.9}], + 'categories:accessibility': ['error', {minScore: 0.9}], + 'categories:best-practices': ['error', {minScore: 0.9}], + 'categories:seo': ['error', {minScore: 0.9}], + }, + }, + upload: { + target: 'temporary-public-storage', + }, + }, +}; \ No newline at end of file diff --git a/local-lighthouse.sh b/local-lighthouse.sh new file mode 100755 index 0000000..29b68df --- /dev/null +++ b/local-lighthouse.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +mkdir -p ./.lighthouseci + +docker run --rm \ +--user 0:0 \ +-v ./dist:/app/dist \ +-v ./.lighthouserc.cjs:/app/.lighthouserc.cjs \ +-v ./.lighthouseci:/app/.lighthouseci \ +-w /app \ +-e CHROME_PATH=/usr/bin/chromium-browser \ +zenika/alpine-chrome:with-node \ +npx @lhci/cli@0.15.x collect \ + --config=/app/.lighthouserc.cjs -- 2.49.1 From 330c96e5a2895b2b2ee5fde2a59fb0a43271f97c Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 11:08:43 +0100 Subject: [PATCH 03/12] ci(lighthouse): add jenkins lighthouse automated audit --- .env.dist | 4 +++- Jenkinsfile | 27 +++++++++++++++++++++++++-- docker-compose.yml | 15 +++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/.env.dist b/.env.dist index 94d81fc..ef9ae76 100644 --- a/.env.dist +++ b/.env.dist @@ -1,2 +1,4 @@ NODE_VERSION=24 -CADDY_VERSION=2.10.2 \ No newline at end of file +CADDY_VERSION=2.10.2 +LHCI_VERSION=0.15.x +ZENIKA_VERSION=124-with-node \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 2140067..5831652 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,6 +2,7 @@ pipeline { agent any environment { DOCKER_HOST = "unix:///var/run/docker.sock" + APP_VERSION = "${env.BRANCH_NAME}-${env.BUILD_NUMBER}" } stages { stage('Build') { @@ -9,12 +10,25 @@ pipeline { // Get Caddy version sh "cp .env.dist .env" // Push portfolio version - sh "echo '\nPORTFOLIO_VERSION=${env.BRANCH_NAME}-${env.BUILD_NUMBER}' >> .env" + sh "echo '\nPORTFOLIO_VERSION=${env.APP_VERSION}' >> .env" echo "Building new portfolio version..." sh "docker compose build" } } + stage('Lighthouse Audit') { + steps { + // Temporary container to get data in /dist folder + // Reuse of just build portfolio image + sh "mkdir -p ./dist-audit ./.lighthouseci" + sh "docker create --name audit-tmp portfolio:${env.APP_VERSION}" + sh "docker cp audit-tmp:/usr/share/caddy/. ./dist-audit" + sh "docker rm audit-tmp" + + // Launch special service in docker compose + sh "docker compose --profile audit run --rm lighthouse-audit" + } + } stage('Deploy') { // Deploy only master branch when { @@ -35,8 +49,17 @@ pipeline { } post { always { - echo "Clean unused image..." + echo "Publish Lighthouse audit..." + publishHTML([ + allowMissing: true, + alwaysLinkToLastBuild: true, + reportDir: '.lighthouseci', + reportFiles: 'index.html', + reportName: 'Lighthouse Report' + ]) + echo "Clean unused image and files..." sh "docker image prune -f" + sh "rm -rf ./dist-audit" } success { echo "Success !" } failure { echo "Failed." } diff --git a/docker-compose.yml b/docker-compose.yml index acdd627..92ae65e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,21 @@ services: networks: - reverse-proxy + lighthouse-audit: + profiles: + - audit + image: zenika/alpine-chrome:${ZENIKA_VERSION} + container_name: lighthouse-audit + user: "0:0" + volumes: + - ./dist-audit:/app/dist + - ./.lighthouseci:/app/.lighthouseci + - ./.lighthouserc.cjs:/app/.lighthouserc.cjs + environment: + - CHROME_PATH=/usr/bin/chromium-browser + working_dir: /app + command: npx @lhci/cli@${LHCI_VERSION} collect --config=/app/.lighthouserc.cjs + networks: reverse-proxy: external: true \ No newline at end of file -- 2.49.1 From 887354c288cbfb6cdd90fcac287b0b04340c7f46 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 11:12:01 +0100 Subject: [PATCH 04/12] fix(lighthouse): add mandatory publishHTML setting --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 5831652..e1863e9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -53,6 +53,7 @@ pipeline { publishHTML([ allowMissing: true, alwaysLinkToLastBuild: true, + keepAll: false, reportDir: '.lighthouseci', reportFiles: 'index.html', reportName: 'Lighthouse Report' -- 2.49.1 From ba71aadcb34a306a68e293ef6e70a00035df4e87 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 11:15:27 +0100 Subject: [PATCH 05/12] fix(lighthouse): fix path for audits config --- docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 92ae65e..804ca11 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,9 +18,9 @@ services: container_name: lighthouse-audit user: "0:0" volumes: - - ./dist-audit:/app/dist - - ./.lighthouseci:/app/.lighthouseci - - ./.lighthouserc.cjs:/app/.lighthouserc.cjs + - ${PWD}/dist-audit:/app/dist + - ${PWD}/.lighthouseci:/app/.lighthouseci + - ${PWD}/.lighthouserc.cjs:/app/.lighthouserc.cjs environment: - CHROME_PATH=/usr/bin/chromium-browser working_dir: /app -- 2.49.1 From 9b261e4333dbc39f920ec6c1e928814ad9d99d7f Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 11:23:16 +0100 Subject: [PATCH 06/12] fix(lighthouse): merge astro data and audit config to fix permission issues --- Jenkinsfile | 5 ++++- docker-compose.yml | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e1863e9..1eb5b96 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,11 +20,14 @@ pipeline { steps { // Temporary container to get data in /dist folder // Reuse of just build portfolio image - sh "mkdir -p ./dist-audit ./.lighthouseci" + sh "mkdir -p ./dist-audit ./.lighthouseci" sh "docker create --name audit-tmp portfolio:${env.APP_VERSION}" sh "docker cp audit-tmp:/usr/share/caddy/. ./dist-audit" sh "docker rm audit-tmp" + // Add audit config in the same folder + sh "cp .lighthouserc.cjs ./dist-audit/audit-config.cjs" + // Launch special service in docker compose sh "docker compose --profile audit run --rm lighthouse-audit" } diff --git a/docker-compose.yml b/docker-compose.yml index 804ca11..1f6ccfd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,13 +18,13 @@ services: container_name: lighthouse-audit user: "0:0" volumes: - - ${PWD}/dist-audit:/app/dist - - ${PWD}/.lighthouseci:/app/.lighthouseci - - ${PWD}/.lighthouserc.cjs:/app/.lighthouserc.cjs + # astro file + config + - ./dist-audit:/app/dist + - ./.lighthouseci:/app/.lighthouseci environment: - CHROME_PATH=/usr/bin/chromium-browser working_dir: /app - command: npx @lhci/cli@${LHCI_VERSION} collect --config=/app/.lighthouserc.cjs + command: npx @lhci/cli@${LHCI_VERSION} collect --config=/app/dist/audit-config.cjs networks: reverse-proxy: -- 2.49.1 From c6b180ff4593b6938d773cfeb949abef07bb5bdd Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 12:16:47 +0100 Subject: [PATCH 07/12] fix(lighthouse): switch to docker volumes --- Jenkinsfile | 31 ++++++++++++++++--------- docker-compose.yml | 57 ++++++++++++++++++++++++---------------------- 2 files changed, 50 insertions(+), 38 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1eb5b96..2c07463 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,18 +18,28 @@ pipeline { } stage('Lighthouse Audit') { steps { - // Temporary container to get data in /dist folder - // Reuse of just build portfolio image - sh "mkdir -p ./dist-audit ./.lighthouseci" + // Create volumes but no run + sh "docker compose --profile audit create lighthouse-audit" + + // Extract astro data from image to tmp-dist sh "docker create --name audit-tmp portfolio:${env.APP_VERSION}" - sh "docker cp audit-tmp:/usr/share/caddy/. ./dist-audit" - sh "docker rm audit-tmp" + sh "mkdir -p ./tmp-dist" + sh "docker cp audit-tmp:/usr/share/caddy/. ./tmp-dist" - // Add audit config in the same folder - sh "cp .lighthouserc.cjs ./dist-audit/audit-config.cjs" + // Inject data from tmp-dist and config to audit container + sh "docker cp ./tmp-dist/. lighthouse-audit:/app/dist/" + sh "docker cp .lighthouserc.cjs lighthouse-audit:/app/dist/audit-config.cjs" - // Launch special service in docker compose - sh "docker compose --profile audit run --rm lighthouse-audit" + // Now run + sh "docker compose --profile audit run lighthouse-audit" + + // Get reports + sh "mkdir -p ./.lighthouseci" + sh "docker cp lighthouse-audit:/app/.lighthouseci/. ./.lighthouseci/" + + // Clean temp + sh "docker rm lighthouse-audit" + sh "rm -rf ./tmp-dist" } } stage('Deploy') { @@ -61,9 +71,8 @@ pipeline { reportFiles: 'index.html', reportName: 'Lighthouse Report' ]) - echo "Clean unused image and files..." + echo "Clean unused image" sh "docker image prune -f" - sh "rm -rf ./dist-audit" } success { echo "Success !" } failure { echo "Failed." } diff --git a/docker-compose.yml b/docker-compose.yml index 1f6ccfd..b1c96d6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,31 +1,34 @@ services: - portfolio: - build: - context: . - args: - - NODE_VERSION=${NODE_VERSION} - - CADDY_VERSION=${CADDY_VERSION} - image: portfolio:${PORTFOLIO_VERSION} - container_name: portfolio - restart: always - networks: - - reverse-proxy +portfolio: + build: + context: . + args: + - NODE_VERSION=${NODE_VERSION} + - CADDY_VERSION=${CADDY_VERSION} + image: portfolio:${PORTFOLIO_VERSION} + container_name: portfolio + restart: always + networks: + - reverse-proxy - lighthouse-audit: - profiles: - - audit - image: zenika/alpine-chrome:${ZENIKA_VERSION} - container_name: lighthouse-audit - user: "0:0" - volumes: - # astro file + config - - ./dist-audit:/app/dist - - ./.lighthouseci:/app/.lighthouseci - environment: - - CHROME_PATH=/usr/bin/chromium-browser - working_dir: /app - command: npx @lhci/cli@${LHCI_VERSION} collect --config=/app/dist/audit-config.cjs +lighthouse-audit: + profiles: + - audit + image: zenika/alpine-chrome:${ZENIKA_VERSION} + container_name: lighthouse-audit + user: "0:0" + volumes: + - audit_dist:/app/dist + - audit_reports:/app/.lighthouseci + environment: + - CHROME_PATH=/usr/bin/chromium-browser + working_dir: /app + command: npx @lhci/cli@${LHCI_VERSION} collect --config=/app/dist/audit-config.cjs + +volumes: +audit_dist: +audit_reports: networks: - reverse-proxy: - external: true \ No newline at end of file +reverse-proxy: + external: true \ No newline at end of file -- 2.49.1 From 079f5a89e7126a257a9884a117e267f05472d316 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 12:20:31 +0100 Subject: [PATCH 08/12] fix(lighthouse): docker-compose error --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b1c96d6..fed7e0b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,8 +26,8 @@ lighthouse-audit: command: npx @lhci/cli@${LHCI_VERSION} collect --config=/app/dist/audit-config.cjs volumes: -audit_dist: -audit_reports: + audit_dist: + audit_reports: networks: reverse-proxy: -- 2.49.1 From 6987009cfb5c49d720f8b911c8d13aaacaf36222 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 12:22:10 +0100 Subject: [PATCH 09/12] fix(lighthouse): docker-compose indent --- docker-compose.yml | 52 +++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index fed7e0b..b9428a8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,34 +1,34 @@ services: -portfolio: - build: - context: . - args: - - NODE_VERSION=${NODE_VERSION} - - CADDY_VERSION=${CADDY_VERSION} - image: portfolio:${PORTFOLIO_VERSION} - container_name: portfolio - restart: always - networks: - - reverse-proxy + portfolio: + build: + context: . + args: + - NODE_VERSION=${NODE_VERSION} + - CADDY_VERSION=${CADDY_VERSION} + image: portfolio:${PORTFOLIO_VERSION} + container_name: portfolio + restart: always + networks: + - reverse-proxy -lighthouse-audit: - profiles: - - audit - image: zenika/alpine-chrome:${ZENIKA_VERSION} - container_name: lighthouse-audit - user: "0:0" - volumes: - - audit_dist:/app/dist - - audit_reports:/app/.lighthouseci - environment: - - CHROME_PATH=/usr/bin/chromium-browser - working_dir: /app - command: npx @lhci/cli@${LHCI_VERSION} collect --config=/app/dist/audit-config.cjs + lighthouse-audit: + profiles: + - audit + image: zenika/alpine-chrome:${ZENIKA_VERSION} + container_name: lighthouse-audit + user: "0:0" + volumes: + - audit_dist:/app/dist + - audit_reports:/app/.lighthouseci + environment: + - CHROME_PATH=/usr/bin/chromium-browser + working_dir: /app + command: npx @lhci/cli@${LHCI_VERSION} collect --config=/app/dist/audit-config.cjs volumes: audit_dist: audit_reports: networks: -reverse-proxy: - external: true \ No newline at end of file + reverse-proxy: + external: true \ No newline at end of file -- 2.49.1 From 71663bcdb105edb6b8424d08e30a5a0346abfdaf Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 12:25:35 +0100 Subject: [PATCH 10/12] fix(lighthouse): change report export path --- .lighthouserc.cjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.lighthouserc.cjs b/.lighthouserc.cjs index 015a3fa..396880f 100644 --- a/.lighthouserc.cjs +++ b/.lighthouserc.cjs @@ -16,7 +16,8 @@ module.exports = { }, }, upload: { - target: 'temporary-public-storage', + target: 'filesystem', + outputDir: './.lighthouseci', // C'est ici que Jenkins ira chercher les fichiers }, }, }; \ No newline at end of file -- 2.49.1 From 0be67f252abe3d33179422c6eb304f8f13c49568 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 12:30:05 +0100 Subject: [PATCH 11/12] fix(lighthouse): safety for temp container --- Jenkinsfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2c07463..a444dc6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,13 +18,16 @@ pipeline { } stage('Lighthouse Audit') { steps { - // Create volumes but no run + + // Create volumes but no run with safety + sh "docker rm -f audit-tmp lighthouse-audit || true" sh "docker compose --profile audit create lighthouse-audit" // Extract astro data from image to tmp-dist sh "docker create --name audit-tmp portfolio:${env.APP_VERSION}" sh "mkdir -p ./tmp-dist" sh "docker cp audit-tmp:/usr/share/caddy/. ./tmp-dist" + sh "docker rm -f audit-tmp" // Inject data from tmp-dist and config to audit container sh "docker cp ./tmp-dist/. lighthouse-audit:/app/dist/" @@ -37,8 +40,8 @@ pipeline { sh "mkdir -p ./.lighthouseci" sh "docker cp lighthouse-audit:/app/.lighthouseci/. ./.lighthouseci/" - // Clean temp - sh "docker rm lighthouse-audit" + // Clean + sh "docker rm -f lighthouse-audit" sh "rm -rf ./tmp-dist" } } -- 2.49.1 From 97bbdfdf02a5c5f88127576ccbad9044f26e00bd Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 12:41:17 +0100 Subject: [PATCH 12/12] fix(lighthouse): fix report files name in jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index a444dc6..fecf9c6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -71,7 +71,7 @@ pipeline { alwaysLinkToLastBuild: true, keepAll: false, reportDir: '.lighthouseci', - reportFiles: 'index.html', + reportFiles: '*.html', reportName: 'Lighthouse Report' ]) echo "Clean unused image" -- 2.49.1