refacto(ci): local and jenkins Lighthouse audit use common docker compose service (#3)
All checks were successful
Portfolio/pipeline/head This commit looks good

Co-authored-by: Lucas <lucasroyer.dev@gmail.com>
Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
Lucas
2026-01-12 16:17:54 +00:00
parent 5a6355957f
commit f234257b5e
4 changed files with 33 additions and 16 deletions

View File

@@ -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