refactor(lighthouse): lighthouse local use same docker compose as jenkins
Some checks failed
Portfolio/pipeline/head There was a failure building this commit
Some checks failed
Portfolio/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -4,6 +4,7 @@ module.exports = {
|
|||||||
staticDistDir: '/app/dist',
|
staticDistDir: '/app/dist',
|
||||||
settings: {
|
settings: {
|
||||||
chromeFlags: '--no-sandbox --disable-setuid-sandbox --headless=new --disable-gpu --disable-dev-shm-usage',
|
chromeFlags: '--no-sandbox --disable-setuid-sandbox --headless=new --disable-gpu --disable-dev-shm-usage',
|
||||||
|
targets: ['filesystem'],
|
||||||
},
|
},
|
||||||
numberOfRuns: 1
|
numberOfRuns: 1
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- CHROME_PATH=/usr/bin/chromium-browser
|
- CHROME_PATH=/usr/bin/chromium-browser
|
||||||
working_dir: /app
|
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:
|
volumes:
|
||||||
audit_dist:
|
audit_dist:
|
||||||
|
|||||||
@@ -1,14 +1,28 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
mkdir -p ./.lighthouseci
|
# Clean old audits and containers
|
||||||
|
rm -rf ./.lighthouseci
|
||||||
|
docker rm -f lighthouse-audit || true
|
||||||
|
|
||||||
docker run --rm \
|
# Load env file and avoid warning for unused portofolio version
|
||||||
--user 0:0 \
|
if [ -f .env.dist ]; then
|
||||||
-v ./dist:/app/dist \
|
export $(grep -v '^#' .env.dist | xargs)
|
||||||
-v ./.lighthouserc.cjs:/app/.lighthouserc.cjs \
|
fi
|
||||||
-v ./.lighthouseci:/app/.lighthouseci \
|
export PORTFOLIO_VERSION="local-audit"
|
||||||
-w /app \
|
|
||||||
-e CHROME_PATH=/usr/bin/chromium-browser \
|
# Create container but no start
|
||||||
zenika/alpine-chrome:with-node \
|
docker compose --profile audit create --no-build --remove-orphans lighthouse-audit
|
||||||
npx @lhci/cli@0.15.x collect \
|
|
||||||
--config=/app/.lighthouserc.cjs
|
# 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
|
||||||
Reference in New Issue
Block a user