- Déplace add_team_link.py et add_team_link.sh dans docker/ - Remplace les heredocs par des COPY dans Dockerfile.business - Évite l'erreur de parsing 'unknown instruction: import' Compatibilité Portainer sans syntaxe heredoc.
200 lines
11 KiB
Docker
200 lines
11 KiB
Docker
# syntax=docker/dockerfile:1.4
|
|
# 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 cytoscape cytoscape-cose-bilkent echarts-for-react
|
|
|
|
# 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 cytoscape cytoscape-cose-bilkent echarts-for-react
|
|
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/
|
|
|
|
# Générer les données de visualisation équipe si nécessaire
|
|
RUN if [ ! -f "public/team-visualization-data.json" ]; then \
|
|
echo "⚠️ team-visualization-data.json non trouvé, génération..." && \
|
|
node scripts/generate-team-visualization-data.js && \
|
|
echo "✅ Données de visualisation équipe générées"; \
|
|
else \
|
|
echo "✅ team-visualization-data.json existe déjà"; \
|
|
fi && \
|
|
echo "🔍 Vérification contenu team-visualization-data.json:" && \
|
|
ls -la public/team-visualization-data.json && \
|
|
head -20 public/team-visualization-data.json
|
|
|
|
# Copier les fichiers nécessaires dans .techradar avant le build (comme le fait techradar.js)
|
|
RUN rm -rf .techradar/data/radar && \
|
|
mkdir -p .techradar/data/radar/2025-01-15 && \
|
|
cp -r radar-business/2025-01-15/* .techradar/data/radar/2025-01-15/ && \
|
|
# Supprimer toute release de démo (2017-03-01, 2024-03-01, etc.) éventuellement recopiée depuis le package
|
|
find .techradar/data/radar -mindepth 1 -maxdepth 1 ! -name '2025-01-15' -exec rm -rf {} + && \
|
|
cp radar-business/config-business.json .techradar/data/config.json && \
|
|
rm -rf .techradar/public && mkdir -p .techradar/public && \
|
|
cp -r public/* .techradar/public/ && \
|
|
cp public/team.html .techradar/public/team.html 2>/dev/null || true && \
|
|
cp public/team-visualization-data.json .techradar/public/team-visualization-data.json 2>/dev/null || true && \
|
|
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"
|
|
|
|
# Diagnostic : compter les fichiers markdown copiés dans .techradar/data/radar
|
|
RUN echo "📊 Comptage des fichiers .md dans .techradar/data/radar" && \
|
|
find .techradar/data/radar -name "*.md" | wc -l && \
|
|
find .techradar/data/radar -name "*.md" | head -10
|
|
|
|
# Créer la page Next.js /team ET un fichier HTML statique /team/index.html
|
|
# La page Next.js pour le routing, le HTML statique pour garantir l'affichage
|
|
RUN mkdir -p .techradar/src/pages
|
|
COPY docker/team-page.tsx .techradar/src/pages/team.tsx
|
|
|
|
# Script Python pour ajouter le lien Équipe dans Navigation.tsx (supprime TOUS les doublons)
|
|
COPY docker/add_team_link.py /tmp/add_team_link.py
|
|
|
|
# Script shell pour gérer l'ajout du lien Équipe
|
|
COPY docker/add_team_link.sh /tmp/add_team_link.sh
|
|
RUN chmod +x /tmp/add_team_link.sh && \
|
|
echo "🔍 VÉRIFICATION: Scripts modifiés:" && \
|
|
echo "=== team-block-script.js ===" && \
|
|
head -10 public/team-block-script.js && \
|
|
echo "=== strategie-script.js ===" && \
|
|
grep -A 2 -B 1 "__blockTeamPages" public/strategie-script.js || echo "❌ Protection non trouvée" && \
|
|
echo "=== config-business.json ===" && \
|
|
grep "jsFile" radar-business/config-business.json
|
|
|
|
# Exécuter le script
|
|
RUN /tmp/add_team_link.sh
|
|
|
|
# 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 && \
|
|
if [ -d "public/team" ]; then \
|
|
mkdir -p out/team && \
|
|
cp -rv public/team/* out/team/ && echo "✅ /team/index.html copié dans out/team/"; \
|
|
elif [ -d "/app/.techradar/public/team" ]; then \
|
|
mkdir -p out/team && \
|
|
cp -rv /app/.techradar/public/team/* out/team/ && echo "✅ /team/index.html copié depuis /app/.techradar/public/team/"; \
|
|
fi && \
|
|
echo "🔍 VÉRIFICATION: team.html dans out/:" && \
|
|
ls -la out/team.html 2>/dev/null || echo "❌ team.html absent de out/" && \
|
|
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 -qE '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" && \
|
|
echo "" && \
|
|
echo "🔍 Vérification des doublons dans le HTML généré..." && \
|
|
if [ -f "out/index.html" ]; then \
|
|
header_count=$(grep -oE '<header|<nav[^>]*>' out/index.html | wc -l | tr -d ' '); \
|
|
nav_count=$(grep -oE '<nav[^>]*>' out/index.html | wc -l | tr -d ' '); \
|
|
logo_count=$(grep -oE 'logo\.svg|logoFile|CoeurBox' out/index.html | wc -l | tr -d ' '); \
|
|
echo "📊 HTML généré: $header_count header/nav, $nav_count nav, $logo_count logo"; \
|
|
if [ "$header_count" -gt "2" ] || [ "$nav_count" -gt "2" ]; then \
|
|
echo "❌ ERREUR: Duplication détectée dans le HTML généré!"; \
|
|
echo "📄 Recherche des headers/nav dans index.html:"; \
|
|
grep -nE '<header|<nav' out/index.html | head -10 || true; \
|
|
exit 1; \
|
|
else \
|
|
echo "✅ HTML généré correct (pas de duplication structurelle)"; \
|
|
fi; \
|
|
if [ "$logo_count" -gt "5" ]; then \
|
|
echo "⚠️ ATTENTION: $logo_count références au logo dans le HTML (possible duplication)"; \
|
|
else \
|
|
echo "✅ Références logo correctes dans le HTML"; \
|
|
fi; \
|
|
else \
|
|
echo "⚠️ out/index.html non trouvé, vérification HTML ignorée"; \
|
|
fi
|
|
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"]
|