perf: more secure deploy
All checks were successful
jenkins-ci Build successful

This commit is contained in:
2026-01-27 11:25:45 +00:00
parent 61dde9642b
commit c79c49e6d0
3 changed files with 25 additions and 13 deletions

1
.gitignore vendored
View File

@@ -0,0 +1 @@
/html-prod

View File

@@ -11,10 +11,10 @@ module.exports = {
assert: { assert: {
// On utilise 'preset: lighthouse:recommended' ou on simplifie les assertions // On utilise 'preset: lighthouse:recommended' ou on simplifie les assertions
assertions: { assertions: {
'categories:performance': ['error', {minScore: 0.1}], 'categories:performance': ['warn', {minScore: 0.1}],
'categories:accessibility': ['error', {minScore: 0.1}], 'categories:accessibility': ['warn', {minScore: 0.1}],
'categories:best-practices': ['error', {minScore: 0.1}], 'categories:best-practices': ['warn', {minScore: 0.1}],
'categories:seo': ['error', {minScore: 0.1}], 'categories:seo': ['warn', {minScore: 0.1}],
}, },
}, },
upload: { upload: {

29
Jenkinsfile vendored
View File

@@ -7,7 +7,7 @@ pipeline {
TOOLBOX_PATH ="/home/lucas/services/static-sites/static-toolbox" TOOLBOX_PATH ="/home/lucas/services/static-sites/static-toolbox"
SOURCE_DIR = "html" SOURCE_DIR = "html"
DEPLOY_PATH = "/home/lucas/services/static-sites/site-veloboomboom/html-prod" DEPLOY_ROOT = "/home/lucas/services/static-sites/site-veloboomboom"
} }
stages { stages {
stage('Check toolbox') { stage('Check toolbox') {
@@ -39,12 +39,18 @@ pipeline {
echo "Running Lighthouse audit..." echo "Running Lighthouse audit..."
// Clean old report and prepare reports and npm cache folders // Clean old report and prepare reports and npm cache folders
sh """ sh """
docker run --rm --volumes-from jenkins -w \$(pwd) alpine:latest \ docker run --rm \
sh -c "rm -rf ./.lighthouseci && mkdir -p ./.lighthouseci && chmod 777 ./.lighthouseci" --volumes-from jenkins \
-v /home/lucas/.npm-cache:/tmp/npm-cache \
# On s'assure que le dossier existe et qu'il est accessible par tous les conteneurs -w \$(pwd) \
docker run --rm -v /home/lucas/.npm-cache:/tmp/npm-cache alpine:latest \ alpine:latest \
sh -c "mkdir -p /tmp/npm-cache && chmod 777 /tmp/npm-cache" sh -c " \
rm -rf ./.lighthouseci && \
mkdir -p ./.lighthouseci && \
chmod 777 ./.lighthouseci && \
mkdir -p /tmp/npm-cache && \
chmod 777 /tmp/npm-cache \
"
""" """
// Run // Run
@@ -69,10 +75,15 @@ pipeline {
sh """ sh """
docker run --rm \ docker run --rm \
--volumes-from jenkins \ --volumes-from jenkins \
-v /home/lucas/services/static-sites/site-veloboomboom:/home/lucas/services/static-sites/site-veloboomboom \ -v ${env.DEPLOY_ROOT}:/site-deploy \
-w \$(pwd) \ -w \$(pwd) \
alpine:latest \ alpine:latest \
sh -c "mkdir -p ../html-new && cp -R html/* ../html-new/ && mv -T ../html-new ../html-prod" sh -c " \
mkdir -p /site-deploy/html-new && \
cp -R html/* /site-deploy/html-new/ && \
rm -rf /site-deploy/html-prod && \
mv /site-deploy/html-new /site-deploy/html-prod \
"
""" """
echo "Reloading Caddy..." echo "Reloading Caddy..."