From 56f9a3b56a72421e76e673c6ab70401e4ea8a947 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 16:49:41 +0100 Subject: [PATCH 1/3] perf(docker): add npm cache --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index b9428a8..eec81ee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,6 +20,7 @@ services: volumes: - audit_dist:/app/dist - audit_reports:/app/.lighthouseci + - npm_cache:/root/.npm environment: - CHROME_PATH=/usr/bin/chromium-browser working_dir: /app @@ -28,6 +29,7 @@ services: volumes: audit_dist: audit_reports: + npm_cache: networks: reverse-proxy: -- 2.49.1 From 6dd33a2c2fceaa45fc8d6f2458a69efd0164abae Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 16:50:49 +0100 Subject: [PATCH 2/3] refactor(lighthouse): lighthouse local use same docker compose as jenkins --- .lighthouserc.cjs | 1 + docker-compose.yml | 2 +- local-lighthouse.sh | 36 +++++++++++++++++++++++++----------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/.lighthouserc.cjs b/.lighthouserc.cjs index 396880f..2e1b3a6 100644 --- a/.lighthouserc.cjs +++ b/.lighthouserc.cjs @@ -4,6 +4,7 @@ module.exports = { staticDistDir: '/app/dist', settings: { chromeFlags: '--no-sandbox --disable-setuid-sandbox --headless=new --disable-gpu --disable-dev-shm-usage', + targets: ['filesystem'], }, numberOfRuns: 1 }, diff --git a/docker-compose.yml b/docker-compose.yml index eec81ee..899c0d2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,7 +24,7 @@ services: environment: - CHROME_PATH=/usr/bin/chromium-browser working_dir: /app - command: npx @lhci/cli@${LHCI_VERSION} collect --config=/app/dist/audit-config.cjs + command: npx --prefer-offline @lhci/cli@${LHCI_VERSION} autorun --config=/app/dist/audit-config.cjs volumes: audit_dist: diff --git a/local-lighthouse.sh b/local-lighthouse.sh index 29b68df..a78f616 100755 --- a/local-lighthouse.sh +++ b/local-lighthouse.sh @@ -1,14 +1,28 @@ #!/bin/bash -mkdir -p ./.lighthouseci +# Clean old audits and containers +rm -rf ./.lighthouseci +docker rm -f lighthouse-audit || true -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 +# Load env file and avoid warning for unused portofolio version +if [ -f .env.dist ]; then + export $(grep -v '^#' .env.dist | xargs) +fi +export PORTFOLIO_VERSION="local-audit" + +# Create container but no start +docker compose --profile audit create --no-build --remove-orphans lighthouse-audit + +# Inject data and config to container +docker cp ./dist/. lighthouse-audit:/app/dist/ +docker cp .lighthouserc.cjs lighthouse-audit:/app/dist/audit-config.cjs + +# Now run +docker start -a lighthouse-audit + +# Get reports +mkdir -p ./.lighthouseci +docker cp lighthouse-audit:/app/.lighthouseci/. ./.lighthouseci/ + +# Clean container +docker rm -f lighthouse-audit \ No newline at end of file -- 2.49.1 From dfa2c59792c8204887a77efbb7976d7a17f39bc8 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Jan 2026 16:56:40 +0100 Subject: [PATCH 3/3] fix(jenkins): fix lighthouse audit launch in jenkinsfile --- Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fecf9c6..0fcbb6b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,9 +21,9 @@ pipeline { // Create volumes but no run with safety sh "docker rm -f audit-tmp lighthouse-audit || true" - sh "docker compose --profile audit create lighthouse-audit" + sh "docker compose --profile audit create --no-build --remove-orphans lighthouse-audit" - // Extract astro data from image to tmp-dist + // Extract astro data from temp container to tmp-dist folder 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" @@ -32,9 +32,10 @@ pipeline { // 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" + sh "rm -rf ./tmp-dist" // Now run - sh "docker compose --profile audit run lighthouse-audit" + sh "docker start -a lighthouse-audit" // Get reports sh "mkdir -p ./.lighthouseci" @@ -42,7 +43,6 @@ pipeline { // Clean sh "docker rm -f lighthouse-audit" - sh "rm -rf ./tmp-dist" } } stage('Deploy') { -- 2.49.1