fix(lighthouse): switch to docker volumes
Some checks failed
Portfolio/pipeline/head There was a failure building this commit

This commit is contained in:
2026-01-12 12:16:47 +01:00
parent 9b261e4333
commit c6b180ff45
2 changed files with 50 additions and 38 deletions

31
Jenkinsfile vendored
View File

@@ -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." }