fix(lighthouse): switch to docker volumes
This commit is contained in:
31
Jenkinsfile
vendored
31
Jenkinsfile
vendored
@@ -18,18 +18,28 @@ pipeline {
|
|||||||
}
|
}
|
||||||
stage('Lighthouse Audit') {
|
stage('Lighthouse Audit') {
|
||||||
steps {
|
steps {
|
||||||
// Temporary container to get data in /dist folder
|
// Create volumes but no run
|
||||||
// Reuse of just build portfolio image
|
sh "docker compose --profile audit create lighthouse-audit"
|
||||||
sh "mkdir -p ./dist-audit ./.lighthouseci"
|
|
||||||
|
// Extract astro data from image to tmp-dist
|
||||||
sh "docker create --name audit-tmp portfolio:${env.APP_VERSION}"
|
sh "docker create --name audit-tmp portfolio:${env.APP_VERSION}"
|
||||||
sh "docker cp audit-tmp:/usr/share/caddy/. ./dist-audit"
|
sh "mkdir -p ./tmp-dist"
|
||||||
sh "docker rm audit-tmp"
|
sh "docker cp audit-tmp:/usr/share/caddy/. ./tmp-dist"
|
||||||
|
|
||||||
// Add audit config in the same folder
|
// Inject data from tmp-dist and config to audit container
|
||||||
sh "cp .lighthouserc.cjs ./dist-audit/audit-config.cjs"
|
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
|
// Now run
|
||||||
sh "docker compose --profile audit run --rm lighthouse-audit"
|
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') {
|
stage('Deploy') {
|
||||||
@@ -61,9 +71,8 @@ pipeline {
|
|||||||
reportFiles: 'index.html',
|
reportFiles: 'index.html',
|
||||||
reportName: 'Lighthouse Report'
|
reportName: 'Lighthouse Report'
|
||||||
])
|
])
|
||||||
echo "Clean unused image and files..."
|
echo "Clean unused image"
|
||||||
sh "docker image prune -f"
|
sh "docker image prune -f"
|
||||||
sh "rm -rf ./dist-audit"
|
|
||||||
}
|
}
|
||||||
success { echo "Success !" }
|
success { echo "Success !" }
|
||||||
failure { echo "Failed." }
|
failure { echo "Failed." }
|
||||||
|
|||||||
@@ -1,31 +1,34 @@
|
|||||||
services:
|
services:
|
||||||
portfolio:
|
portfolio:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
args:
|
args:
|
||||||
- NODE_VERSION=${NODE_VERSION}
|
- NODE_VERSION=${NODE_VERSION}
|
||||||
- CADDY_VERSION=${CADDY_VERSION}
|
- CADDY_VERSION=${CADDY_VERSION}
|
||||||
image: portfolio:${PORTFOLIO_VERSION}
|
image: portfolio:${PORTFOLIO_VERSION}
|
||||||
container_name: portfolio
|
container_name: portfolio
|
||||||
restart: always
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- reverse-proxy
|
- reverse-proxy
|
||||||
|
|
||||||
lighthouse-audit:
|
lighthouse-audit:
|
||||||
profiles:
|
profiles:
|
||||||
- audit
|
- audit
|
||||||
image: zenika/alpine-chrome:${ZENIKA_VERSION}
|
image: zenika/alpine-chrome:${ZENIKA_VERSION}
|
||||||
container_name: lighthouse-audit
|
container_name: lighthouse-audit
|
||||||
user: "0:0"
|
user: "0:0"
|
||||||
volumes:
|
volumes:
|
||||||
# astro file + config
|
- audit_dist:/app/dist
|
||||||
- ./dist-audit:/app/dist
|
- audit_reports:/app/.lighthouseci
|
||||||
- ./.lighthouseci:/app/.lighthouseci
|
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 @lhci/cli@${LHCI_VERSION} collect --config=/app/dist/audit-config.cjs
|
|
||||||
|
volumes:
|
||||||
|
audit_dist:
|
||||||
|
audit_reports:
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
reverse-proxy:
|
reverse-proxy:
|
||||||
external: true
|
external: true
|
||||||
Reference in New Issue
Block a user