- le script supprime maintenant TOUS les liens Équipe existants (même s'il n'y en a qu'un) - puis ajoute un seul lien Équipe au bon endroit - vérifie qu'il n'y a qu'un seul lien après l'opération - évite les doublons même si le script s'exécute plusieurs fois
313 lines
13 KiB
Docker
313 lines
13 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 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
|
|
RUN mkdir -p .techradar/src/pages && \
|
|
cat > .techradar/src/pages/team.tsx << 'EOF'
|
|
import Head from "next/head";
|
|
import { CustomPage } from "@/pages/_app";
|
|
|
|
const TeamPage: CustomPage = () => {
|
|
return (
|
|
<>
|
|
<Head>
|
|
<title>Équipe & Technologies - Laplank</title>
|
|
</Head>
|
|
<div style={{ width: '100%', height: '100vh', border: 'none', margin: 0, padding: 0 }}>
|
|
<iframe
|
|
src="/team.html"
|
|
style={{
|
|
width: '100%',
|
|
height: '100%',
|
|
border: 'none',
|
|
margin: 0,
|
|
padding: 0
|
|
}}
|
|
title="Équipe & Technologies"
|
|
/>
|
|
</div>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default TeamPage;
|
|
EOF
|
|
RUN echo "✅ Page team.tsx créée"
|
|
|
|
# Script Python pour ajouter le lien Équipe dans Navigation.tsx (supprime TOUS les doublons)
|
|
RUN cat > /tmp/add_team_link.py << 'PYEOF'
|
|
#!/usr/bin/env python3
|
|
import sys
|
|
import re
|
|
import os
|
|
|
|
f = ".techradar/src/components/Navigation/Navigation.tsx"
|
|
|
|
try:
|
|
# Vérifier que le fichier existe
|
|
if not os.path.exists(f):
|
|
print(f"❌ Fichier {f} introuvable", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
with open(f, 'r', encoding='utf-8') as file:
|
|
content = file.read()
|
|
|
|
# ÉTAPE 1: Supprimer TOUS les liens Équipe existants (même s'il n'y en a qu'un)
|
|
print("🧹 Nettoyage de tous les liens Équipe existants...")
|
|
lines = content.splitlines(keepends=True)
|
|
if lines and not lines[-1].endswith('\n'):
|
|
lines[-1] = lines[-1] + '\n'
|
|
|
|
new_lines = []
|
|
skip_team_link = False
|
|
team_links_removed = 0
|
|
|
|
i = 0
|
|
while i < len(lines):
|
|
line = lines[i]
|
|
|
|
# Détecter le début d'un lien Équipe
|
|
if ('href="/team"' in line or "href='/team'" in line) and not skip_team_link:
|
|
skip_team_link = True
|
|
team_links_removed += 1
|
|
# Ignorer cette ligne et les lignes suivantes jusqu'à </li>
|
|
i += 1
|
|
continue
|
|
|
|
# Si on est dans un bloc Équipe à supprimer, ignorer jusqu'à </li>
|
|
if skip_team_link:
|
|
if '</li>' in line:
|
|
skip_team_link = False
|
|
i += 1
|
|
continue
|
|
|
|
new_lines.append(line)
|
|
i += 1
|
|
|
|
if team_links_removed > 0:
|
|
print(f"✅ {team_links_removed} lien(s) Équipe supprimé(s)")
|
|
|
|
# ÉTAPE 2: Ajouter un seul lien Équipe au bon endroit
|
|
content_cleaned = ''.join(new_lines)
|
|
lines = content_cleaned.splitlines(keepends=True)
|
|
if lines and not lines[-1].endswith('\n'):
|
|
lines[-1] = lines[-1] + '\n'
|
|
|
|
insert_idx = -1
|
|
for i, line in enumerate(lines):
|
|
if 'href="/overview"' in line:
|
|
for j in range(i, min(i+10, len(lines))):
|
|
if '</Link>' in lines[j] and j+1 < len(lines) and '</li>' in lines[j+1]:
|
|
insert_idx = j + 2
|
|
break
|
|
break
|
|
|
|
if insert_idx > 0:
|
|
new_lines = lines[:insert_idx] + [
|
|
' <li className={styles.item}>\n',
|
|
' <Link href="/team">\n',
|
|
' <span className={styles.label}>👥 Équipe</span>\n',
|
|
' </Link>\n',
|
|
' </li>\n'
|
|
] + lines[insert_idx:]
|
|
with open(f, 'w', encoding='utf-8') as file:
|
|
file.writelines(new_lines)
|
|
|
|
# Vérifier qu'il n'y a qu'un seul lien maintenant
|
|
with open(f, 'r', encoding='utf-8') as file:
|
|
final_content = file.read()
|
|
final_count = len(re.findall(r'href=["\']/team["\']', final_content))
|
|
|
|
if final_count == 1:
|
|
print("✅ Navigation.tsx modifié - 1 seul lien Équipe présent")
|
|
sys.exit(0)
|
|
else:
|
|
print(f"⚠️ Attention: {final_count} lien(s) Équipe détecté(s) après modification", file=sys.stderr)
|
|
sys.exit(1)
|
|
else:
|
|
print("❌ Impossible de trouver l'emplacement pour insérer le lien", file=sys.stderr)
|
|
sys.exit(1)
|
|
except Exception as e:
|
|
print(f"❌ Erreur Python: {e}", file=sys.stderr)
|
|
import traceback
|
|
traceback.print_exc(file=sys.stderr)
|
|
sys.exit(1)
|
|
PYEOF
|
|
|
|
# Script shell pour gérer l'ajout du lien Équipe
|
|
RUN cat > /tmp/add_team_link.sh << 'SHEOF'
|
|
#!/bin/sh
|
|
set -e
|
|
|
|
echo "🔧 Modification de Navigation.tsx pour le lien Équipe..."
|
|
|
|
NAV_FILE=".techradar/src/components/Navigation/Navigation.tsx"
|
|
|
|
# Vérifier que le fichier existe
|
|
if [ ! -f "$NAV_FILE" ]; then
|
|
echo "❌ Fichier $NAV_FILE introuvable"
|
|
echo "📁 Répertoire actuel: $(pwd)"
|
|
echo "📁 Contenu de .techradar/src/components/:"
|
|
ls -la .techradar/src/components/ 2>/dev/null || echo "Répertoire non trouvé"
|
|
exit 1
|
|
fi
|
|
|
|
# Exécuter le script Python
|
|
if python3 /tmp/add_team_link.py; then
|
|
# Vérifier le résultat
|
|
team_count=$(grep -c 'href="/team"' "$NAV_FILE" 2>/dev/null || echo "0")
|
|
echo "📊 Nombre d'occurrences trouvées: $team_count"
|
|
|
|
if [ "$team_count" -eq "1" ]; then
|
|
echo "✅ Lien Équipe présent (1 occurrence)"
|
|
elif [ "$team_count" -gt "1" ]; then
|
|
echo "⚠️ Plusieurs occurrences détectées ($team_count), relance du nettoyage..."
|
|
python3 /tmp/add_team_link.py
|
|
final_count=$(grep -c 'href="/team"' "$NAV_FILE" 2>/dev/null || echo "0")
|
|
echo "✅ Après nettoyage: $final_count occurrence(s)"
|
|
else
|
|
echo "❌ Lien Équipe non trouvé après modification"
|
|
echo "📄 Aperçu de Navigation.tsx (premières 50 lignes):"
|
|
head -50 "$NAV_FILE" || true
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "❌ Erreur lors de l'exécution du script Python"
|
|
exit 1
|
|
fi
|
|
SHEOF
|
|
RUN chmod +x /tmp/add_team_link.sh
|
|
|
|
# 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 && \
|
|
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"]
|