Compare commits
5 Commits
579ab3ec47
...
f1794abe7e
| Author | SHA1 | Date | |
|---|---|---|---|
| f1794abe7e | |||
| 351256483f | |||
| db7e655d4f | |||
| 952c75127a | |||
| fa8e84514a |
@@ -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
|
||||||
},
|
},
|
||||||
@@ -16,7 +17,8 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
upload: {
|
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') {
|
stage('Lighthouse Audit') {
|
||||||
steps {
|
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
|
// Create volumes but no run with safety
|
||||||
sh "docker compose --profile audit run --rm lighthouse-audit"
|
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') {
|
stage('Deploy') {
|
||||||
@@ -55,12 +71,11 @@ pipeline {
|
|||||||
alwaysLinkToLastBuild: true,
|
alwaysLinkToLastBuild: true,
|
||||||
keepAll: false,
|
keepAll: false,
|
||||||
reportDir: '.lighthouseci',
|
reportDir: '.lighthouseci',
|
||||||
reportFiles: 'index.html',
|
reportFiles: '*.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." }
|
||||||
|
|||||||
@@ -18,13 +18,18 @@ services:
|
|||||||
container_name: lighthouse-audit
|
container_name: lighthouse-audit
|
||||||
user: "0:0"
|
user: "0:0"
|
||||||
volumes:
|
volumes:
|
||||||
- ./dist-audit:/app/dist
|
- audit_dist:/app/dist
|
||||||
- ./.lighthouseci:/app/.lighthouseci
|
- audit_reports:/app/.lighthouseci
|
||||||
- ./.lighthouserc.cjs:/app/.lighthouserc.cjs
|
- npm_cache:/root/.npm
|
||||||
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/.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:
|
networks:
|
||||||
reverse-proxy:
|
reverse-proxy:
|
||||||
|
|||||||
@@ -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