diff --git a/Jenkinsfile b/Jenkinsfile index ac0e9fd..c446770 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -89,6 +89,9 @@ pipeline { steps { echo "⚙️ Build de l'application Next.js..." script { + // Nettoyer le cache Next.js pour forcer une reconstruction complète + sh 'rm -rf .next node_modules/.cache' + // Next.js peut échouer avec des erreurs SSR mais générer quand même un build fonctionnel def buildStatus = sh(script: 'npm ci && npm run build', returnStatus: true) @@ -127,7 +130,7 @@ pipeline { } sh """ - docker build ${buildArgs} -t ${REGISTRY_URL}/${IMAGE_NAME}:${env.TAG} . + docker build --no-cache ${buildArgs} -t ${REGISTRY_URL}/${IMAGE_NAME}:${env.TAG} . docker tag ${REGISTRY_URL}/${IMAGE_NAME}:${env.TAG} ${REGISTRY_URL}/${IMAGE_NAME}:latest """ } diff --git a/next.config.js b/next.config.js index 5a2ae88..0727e70 100644 --- a/next.config.js +++ b/next.config.js @@ -17,6 +17,15 @@ const nextConfig = { }, // Generate error pages instead of failing build on prerender errors staticPageGenerationTimeout: 120, + // Generate build ID with timestamp to avoid cache issues + generateBuildId: async () => { + return `build-${Date.now()}`; + }, + // Disable cache for assets to ensure fresh content + onDemandEntries: { + maxInactiveAge: 25 * 1000, + pagesBufferLength: 2, + }, }; module.exports = nextConfig;