fix(lighthouse): switch to docker volumes
This commit is contained in:
32
Jenkinsfile
vendored
32
Jenkinsfile
vendored
@@ -18,15 +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"
|
||||
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"
|
||||
// Create volumes but no run
|
||||
sh "docker compose --profile audit create lighthouse-audit"
|
||||
|
||||
// Launch special service in docker compose
|
||||
sh "docker compose --profile audit run --rm lighthouse-audit"
|
||||
// Extract astro data from image to tmp-dist
|
||||
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"
|
||||
|
||||
// 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"
|
||||
|
||||
// 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') {
|
||||
@@ -58,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." }
|
||||
|
||||
Reference in New Issue
Block a user