Files
TechradarDev/Dockerfile.business
syoul 991e557b68 fix: amélioration gestion erreurs avec set +e pour diagnostic
- Désactivation temporaire de set -e pour voir toutes les erreurs
- Capture du code de sortie du script
- Affichage du contenu de Navigation.tsx en cas d'échec
- Réactivation de set -e à la fin
2025-12-07 08:02:42 +01:00

164 lines
8.3 KiB
Docker

# Utiliser une image Node.js légère
FROM node:20-alpine
# Build arguments pour invalider le cache si nécessaire
ARG BUILD_DATE=unknown
ARG BUILD_VERSION=unknown
ARG CACHE_BUST=1
LABEL build.date="${BUILD_DATE}" \
build.version="${BUILD_VERSION}" \
cache.bust="${CACHE_BUST}"
# Invalider le cache en utilisant CACHE_BUST dans une instruction RUN
# Cela force Docker à reconstruire à partir de cette ligne si CACHE_BUST change
# Utiliser CACHE_BUST dans une variable d'environnement pour forcer l'invalidation
RUN echo "Cache bust: ${CACHE_BUST}" && \
echo "Build date: ${BUILD_DATE}" && \
date && \
echo "${CACHE_BUST}" > /tmp/cache_bust.txt
WORKDIR /app
# Variables d'environnement à définir AVANT npm install
ENV HUSKY=0
ENV HUSKY_SKIP_INSTALL=1
ENV NODE_PATH=/app/node_modules
ENV NODE_ENV=production
# Installation des dépendances système
RUN apk add --no-cache git python3
# Copie des fichiers de dépendances
COPY package.json package-lock.json* ./
# Installation des dépendances Node
RUN npm install --legacy-peer-deps --ignore-scripts
# Patch du package aoe_technology_radar pour inclure gray-matter dans les dépendances runtime
RUN node -e "const fs=require('fs');const pkgPath='./node_modules/aoe_technology_radar/package.json';const pkg=JSON.parse(fs.readFileSync(pkgPath,'utf8'));pkg.dependencies=pkg.dependencies||{};pkg.dependencies['gray-matter']='^4.0.3';pkg.dependencies['postcss']='^8.4.47';pkg.scripts=pkg.scripts||{};pkg.scripts.prepare='';fs.writeFileSync(pkgPath,JSON.stringify(pkg,null,2));"
# Copie du reste du projet
COPY . .
RUN chmod +x scripts/start-business.sh
# Préparer .techradar une fois pour toutes (évite les réinstallations au runtime)
# Le script techradar.js crée automatiquement .techradar lors de l'exécution
# Création manuelle de .techradar en copiant depuis node_modules
RUN mkdir -p .techradar && \
cp -r node_modules/aoe_technology_radar/* .techradar/
# Créer le fichier hash pour éviter la recréation (calculé séparément pour éviter les problèmes d'échappement)
RUN node -e "const crypto=require('crypto');const fs=require('fs');const hash=crypto.createHash('sha256').update(fs.readFileSync('package.json')).digest('hex');fs.writeFileSync('.techradar/hash',hash);"
RUN node -e "const fs=require('fs');const p='.techradar/package.json';if(!fs.existsSync(p)){console.error('.techradar/package.json not found');process.exit(1);}const pkg=JSON.parse(fs.readFileSync(p,'utf8'));pkg.scripts=pkg.scripts||{};pkg.scripts.prepare='';fs.writeFileSync(p,JSON.stringify(pkg,null,2));"
# Installer les dépendances dans .techradar (y compris devDependencies pour tsx nécessaire à build:data)
RUN cd .techradar && npm install --legacy-peer-deps --include=dev
RUN cd .techradar && npm run build:icons
# --- CONFIGURATION BUSINESS ---
# Application de la logique Business (remplacement de la config et des données)
# Préserver la structure de dossiers par date pour que le framework puisse parser les dates
RUN cp radar-business/config-business.json config.json && \
rm -rf radar/* && \
mkdir -p radar/2025-01-15 && \
cp -r radar-business/2025-01-15/* radar/2025-01-15/
# Copier les fichiers nécessaires dans .techradar avant le build (comme le fait techradar.js)
RUN mkdir -p .techradar/data && \
cp -r radar .techradar/data/radar && \
cp -r public .techradar/public && \
cp config.json .techradar/data/config.json && \
cp about.md .techradar/data/about.md 2>/dev/null || echo "about.md not found, skipping" && \
cp custom.css .techradar/src/styles/custom.css 2>/dev/null || echo "custom.css not found, skipping" && \
echo "Fichiers public copiés" && \
echo "📁 Vérification des fichiers team dans .techradar/public/:" && \
ls -la .techradar/public/ | grep -E "(team\.html|team-visualization)" && echo "✅ Fichiers team trouvés" || (echo "⚠️ Fichiers team non trouvés dans .techradar/public/" && echo "📁 Contenu de public/ source:" && ls -la public/ | head -10) && \
echo "📁 Vérification que team.html existe dans public/ source:" && \
test -f public/team.html && echo "✅ public/team.html existe" || echo "❌ public/team.html n'existe pas"
# Créer la page Next.js /team et modifier Navigation
# Désactiver temporairement set -e pour cette section pour voir toutes les erreurs
RUN set +e && \
chmod +x scripts/create-team-page.sh && \
echo "🚀 Exécution de create-team-page.sh..." && \
echo "📋 État de Navigation.tsx AVANT modification:" && \
(grep -A 3 'href="/overview"' .techradar/src/components/Navigation/Navigation.tsx || echo "Pattern overview non trouvé") && \
echo "" && \
./scripts/create-team-page.sh; \
SCRIPT_EXIT=$?; \
echo "Script exit code: $SCRIPT_EXIT" && \
if [ $SCRIPT_EXIT -ne 0 ]; then \
echo "❌ Script create-team-page.sh a échoué avec code $SCRIPT_EXIT"; \
echo "📄 Contenu de Navigation.tsx après échec:"; \
cat .techradar/src/components/Navigation/Navigation.tsx 2>/dev/null || echo "Fichier non accessible"; \
exit 1; \
fi && \
echo "✅ Script create-team-page.sh terminé" && \
echo "" && \
echo "📋 Vérification de Navigation.tsx:" && \
if grep -q 'href="/team"' .techradar/src/components/Navigation/Navigation.tsx; then \
echo "✅ Lien Équipe trouvé dans Navigation.tsx"; \
echo "📄 Extrait de Navigation.tsx avec le lien:"; \
grep -A 3 'href="/team"' .techradar/src/components/Navigation/Navigation.tsx; \
else \
echo "❌ Lien Équipe NON trouvé dans Navigation.tsx"; \
echo "📄 Contenu complet de Navigation.tsx:"; \
cat .techradar/src/components/Navigation/Navigation.tsx; \
exit 1; \
fi && \
echo "" && \
echo "📋 Vérification de team.tsx:" && \
if [ -f .techradar/src/pages/team.tsx ]; then \
echo "✅ team.tsx existe"; \
else \
echo "❌ team.tsx n'existe pas"; \
echo "📁 Contenu de .techradar/src/pages/:"; \
ls -la .techradar/src/pages/ 2>/dev/null || echo "Dossier pages/ non trouvé"; \
exit 1; \
fi && \
set -e
# Builder l'application en mode production pour éviter Fast Refresh
# Utiliser WORKDIR pour changer de répertoire de manière fiable
WORKDIR /app/.techradar
RUN npm run build:data
RUN npm run build
# S'assurer que team.html et team-visualization-data.json sont copiés dans out/
# Next.js en mode export copie automatiquement les fichiers de public/, mais vérifions quand même
RUN if [ -d "out" ]; then \
echo "📁 Contenu de out/ avant copie:" && \
ls -la out/ | head -10 && \
echo "" && \
echo "🔍 Recherche de team.html..." && \
if [ -f "public/team.html" ]; then \
cp -v public/team.html out/team.html && echo "✅ team.html copié depuis public/ vers out/"; \
elif [ -f "/app/public/team.html" ]; then \
cp -v /app/public/team.html out/team.html && echo "✅ team.html copié depuis /app/public/ vers out/"; \
else \
echo "⚠️ team.html introuvable dans public/ ou /app/public/"; \
echo "📁 Contenu de public/:" && \
ls -la public/ 2>/dev/null | head -10 || echo "public/ non accessible"; \
echo "📁 Contenu de /app/public/:" && \
ls -la /app/public/ 2>/dev/null | head -10 || echo "/app/public/ non accessible"; \
fi && \
if [ -f "public/team-visualization-data.json" ]; then \
cp -v public/team-visualization-data.json out/team-visualization-data.json && echo "✅ team-visualization-data.json copié dans out/"; \
else \
echo "⚠️ public/team-visualization-data.json introuvable"; \
fi && \
echo "" && \
echo "📁 Vérification finale dans out/:" && \
ls -la out/ | grep -E "(team\.html|team-visualization)" && echo "✅ Fichiers team présents dans out/" || echo "⚠️ Fichiers team non trouvés dans out/"; \
else \
echo "❌ Dossier out/ introuvable après build"; \
ls -la . | head -20; \
fi && \
echo "" && \
echo "📋 Vérification finale de Navigation.tsx après build:" && \
grep -q 'href="/team"' src/components/Navigation/Navigation.tsx && echo "✅ Lien Équipe toujours présent dans Navigation.tsx après build" || echo "❌ Lien Équipe absent de Navigation.tsx après build"
WORKDIR /app
# Exposition du port interne
EXPOSE 3000
# Démarrage du serveur via script (exporte les variables avant npm run serve)
CMD ["./scripts/start-business.sh"]