Compare commits
11 Commits
develop
...
579ab3ec47
| Author | SHA1 | Date | |
|---|---|---|---|
| 579ab3ec47 | |||
| 5667aee8c6 | |||
| 97662829d2 | |||
| 9f0e1c2ea7 | |||
| 587c94c695 | |||
| 747948041e | |||
| c6c1e949be | |||
| 65b9e80545 | |||
| 1d30e62aeb | |||
| 1ac38be75b | |||
| 2daa0dcffb |
@@ -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
|
||||
},
|
||||
@@ -16,7 +17,8 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
upload: {
|
||||
target: 'temporary-public-storage',
|
||||
target: 'filesystem',
|
||||
outputDir: './.lighthouseci', // C'est ici que Jenkins ira chercher les fichiers
|
||||
},
|
||||
},
|
||||
};
|
||||
37
Jenkinsfile
vendored
37
Jenkinsfile
vendored
@@ -18,15 +18,31 @@ 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"
|
||||
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"
|
||||
// Create volumes but no run with safety
|
||||
sh "docker rm -f audit-tmp lighthouse-audit || true"
|
||||
sh "docker compose --profile audit create --no-build --remove-orphans lighthouse-audit"
|
||||
|
||||
// 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"
|
||||
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/"
|
||||
sh "docker cp .lighthouserc.cjs lighthouse-audit:/app/dist/audit-config.cjs"
|
||||
sh "rm -rf ./tmp-dist"
|
||||
|
||||
// Now run
|
||||
sh "docker start -a lighthouse-audit"
|
||||
|
||||
// Get reports
|
||||
sh "mkdir -p ./.lighthouseci"
|
||||
sh "docker cp lighthouse-audit:/app/.lighthouseci/. ./.lighthouseci/"
|
||||
|
||||
// Clean
|
||||
sh "docker rm -f lighthouse-audit"
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
@@ -55,12 +71,11 @@ pipeline {
|
||||
alwaysLinkToLastBuild: true,
|
||||
keepAll: false,
|
||||
reportDir: '.lighthouseci',
|
||||
reportFiles: 'index.html',
|
||||
reportFiles: '*.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." }
|
||||
|
||||
@@ -18,13 +18,18 @@ services:
|
||||
container_name: lighthouse-audit
|
||||
user: "0:0"
|
||||
volumes:
|
||||
- ./dist-audit:/app/dist
|
||||
- ./.lighthouseci:/app/.lighthouseci
|
||||
- ./.lighthouserc.cjs:/app/.lighthouserc.cjs
|
||||
- audit_dist:/app/dist
|
||||
- audit_reports:/app/.lighthouseci
|
||||
- npm_cache:/root/.npm
|
||||
environment:
|
||||
- CHROME_PATH=/usr/bin/chromium-browser
|
||||
working_dir: /app
|
||||
command: npx @lhci/cli@${LHCI_VERSION} collect --config=/app/.lighthouserc.cjs
|
||||
command: npx --prefer-offline @lhci/cli@${LHCI_VERSION} autorun --config=/app/dist/audit-config.cjs
|
||||
|
||||
volumes:
|
||||
audit_dist:
|
||||
audit_reports:
|
||||
npm_cache:
|
||||
|
||||
networks:
|
||||
reverse-proxy:
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user