fix: force fresh builds to prevent cache issues between localhost and deployed site
- Add --no-cache flag to Docker build to force complete rebuild - Clean .next and node_modules cache before each build - Generate unique build ID with timestamp for each deployment - Configure onDemandEntries to reduce cache duration This ensures deployed site always matches localhost by preventing: - Docker layer caching - Next.js build cache - Browser cache of stale assets 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
21ccce0f3a
commit
5d5375ff6b
5
Jenkinsfile
vendored
5
Jenkinsfile
vendored
|
|
@ -89,6 +89,9 @@ pipeline {
|
||||||
steps {
|
steps {
|
||||||
echo "⚙️ Build de l'application Next.js..."
|
echo "⚙️ Build de l'application Next.js..."
|
||||||
script {
|
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
|
// 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)
|
def buildStatus = sh(script: 'npm ci && npm run build', returnStatus: true)
|
||||||
|
|
||||||
|
|
@ -127,7 +130,7 @@ pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
sh """
|
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
|
docker tag ${REGISTRY_URL}/${IMAGE_NAME}:${env.TAG} ${REGISTRY_URL}/${IMAGE_NAME}:latest
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,15 @@ const nextConfig = {
|
||||||
},
|
},
|
||||||
// Generate error pages instead of failing build on prerender errors
|
// Generate error pages instead of failing build on prerender errors
|
||||||
staticPageGenerationTimeout: 120,
|
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;
|
module.exports = nextConfig;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user