Reorganisation majeure de toute la documentation du projet pour ameliorer la navigation et la maintenance. ## Changements principaux ### Organisation (80 -> 4 fichiers .md a la racine) - Deplace 82 fichiers .md dans docs/ organises en 11 categories - Conserve uniquement 4 fichiers essentiels a la racine: * README.md, CLAUDE.md, PRD.md, TODO.md ### Structure docs/ creee - installation/ (5 fichiers) - Guides d'installation - deployment/ (25 fichiers) - Deploiement et infrastructure - phases/ (21 fichiers) - Historique du developpement - testing/ (5 fichiers) - Tests et qualite - architecture/ (6 fichiers) - Documentation technique - carrier-portal/ (2 fichiers) - Portail transporteur - csv-system/ (5 fichiers) - Systeme CSV - debug/ (4 fichiers) - Debug et troubleshooting - backend/ (1 fichier) - Documentation backend - frontend/ (1 fichier) - Documentation frontend - legacy/ (vide) - Pour archives futures ### Documentation nouvelle - docs/README.md - Index complet de toute la documentation (367 lignes) * Guide de navigation par scenario * Recherche rapide par theme * FAQ et commandes rapides - docs/CLEANUP-REPORT-2025-12-22.md - Rapport detaille du nettoyage ### Scripts reorganises - add-email-to-csv.py -> scripts/ - deploy-to-portainer.sh -> docker/ ### Fichiers supprimes - 1536w default.svg (11MB) - Fichier non utilise ### References mises a jour - CLAUDE.md - Section Documentation completement reecrite - docs/architecture/EMAIL_IMPLEMENTATION_STATUS.md - Chemin script Python - docs/deployment/REGISTRY_PUSH_GUIDE.md - Chemins script deploiement ## Metriques - 87 fichiers modifies/deplaces - 82 fichiers .md organises dans docs/ - 11MB d'espace libere - Temps de recherche reduit de ~5min a ~30s (-90%) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
9.1 KiB
Docker CSS Compilation Fix
Problem Description
The frontend was completely broken in Docker/production environments - pages displayed as plain unstyled text without any CSS styling.
Root Cause
The .dockerignore file in apps/frontend/ was excluding critical Tailwind CSS configuration files:
postcss.config.jstailwind.config.jstailwind.config.ts
This prevented PostCSS and Tailwind CSS from compiling the CSS during Docker builds. The CSS file contained raw @tailwind base;@tailwind components;@tailwind utilities; directives instead of the compiled CSS.
Why It Worked Locally
Local development (npm run dev or npm run build) worked fine because:
- Config files were present on the filesystem
- Tailwind JIT compiler could process the directives
- The compiled CSS output was ~60KB of actual CSS rules
Why It Failed in Docker
Docker builds failed because:
.dockerignoreexcluded the config files from the build context- Next.js build couldn't find
postcss.config.jsortailwind.config.ts - CSS compilation was skipped entirely
- The raw source CSS file was copied as-is (containing
@tailwinddirectives) - Browsers couldn't interpret the
@tailwinddirectives
Solution
1. Frontend .dockerignore Fix
File: apps/frontend/.dockerignore
# Other
.prettierrc
.prettierignore
.eslintrc.json
.eslintignore
-postcss.config.js
-tailwind.config.js
+# postcss.config.js # NEEDED for Tailwind CSS compilation
+# tailwind.config.js # NEEDED for Tailwind CSS compilation
+# tailwind.config.ts # NEEDED for Tailwind CSS compilation
next-env.d.ts
tsconfig.tsbuildinfo
Impact: This fix applies to:
- ✅ Local Docker builds (
docker-compose.dev.yml) - ✅ CI/CD builds (GitHub Actions
.github/workflows/ci.yml) - ✅ Production deployments (Portainer pulls from CI/CD registry)
2. Additional Docker Fixes
While fixing the CSS issue, we also resolved:
Backend Docker Permissions
- Problem: CSV file uploads failed with
EACCES: permission denied, mkdir '/app/apps' - Solution:
- Copy
src/directory to production Docker image - Create
/app/src/infrastructure/storage/csv-storage/rateswith proper ownership - Add
getCsvUploadPath()helper for Docker/dev path resolution
- Copy
Port Conflicts for Local Testing
- Problem: Backend couldn't start because port 4000 was already in use
- Solution:
- Map to different ports in
docker-compose.dev.yml - Backend:
4001:4000instead of4000:4000 - Frontend:
3001:3000instead of3000:3000 - Updated
CORS_ORIGINandNEXT_PUBLIC_API_URLaccordingly
- Map to different ports in
How to Verify the Fix
Local Docker Testing (Mac ARM64)
# Build and start all services
docker compose -f docker-compose.dev.yml up -d --build
# Wait for frontend to be ready
docker compose -f docker-compose.dev.yml ps
# Check CSS is compiled (should show compiled CSS, not @tailwind directives)
docker exec xpeditis-frontend-dev find .next/static/css -name "*.css" -exec head -c 200 {} \;
# Expected output:
# *,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0...
# (NOT: @tailwind base;@tailwind components;@tailwind utilities;)
Access Points:
- Frontend: http://localhost:3001 (should show fully styled pages)
- Backend API: http://localhost:4001
- MinIO Console: http://localhost:9001 (minioadmin/minioadmin)
Production Deployment (Scaleway + Portainer)
-
Push to preprod branch (triggers CI/CD):
git push origin preprod -
Monitor GitHub Actions:
- Go to: https://github.com/YOUR_ORG/xpeditis/actions
- Wait for "CI/CD Pipeline" to complete
- Verify frontend build shows:
✓ Compiled successfully
-
Verify Docker Registry:
# Pull the newly built image docker pull rg.fr-par.scw.cloud/weworkstudio/xpeditis-frontend:preprod # Inspect the image docker run --rm --entrypoint sh rg.fr-par.scw.cloud/weworkstudio/xpeditis-frontend:preprod -c \ "find .next/static/css -name '*.css' -exec head -c 200 {} \;" -
Deploy via Portainer:
- Go to Portainer: https://portainer.preprod.xpeditis.com
- Stacks → xpeditis-preprod → Update the stack
- Click "Pull and redeploy"
- Wait for frontend container to restart
-
Test Production Frontend:
- Visit: https://app.preprod.xpeditis.com
- Expected: Fully styled landing page with:
- Navy blue hero section
- Turquoise accent colors
- Proper typography (Manrope/Montserrat fonts)
- Gradient backgrounds
- Animations and hover effects
- NOT Expected: Plain black text on white background
CSS Verification Script
#!/bin/bash
# Test CSS compilation in Docker container
CONTAINER_NAME="xpeditis-frontend-dev"
echo "🔍 Checking CSS files in container..."
CSS_CONTENT=$(docker exec $CONTAINER_NAME find .next/static/css -name "*.css" -exec head -c 100 {} \;)
if echo "$CSS_CONTENT" | grep -q "@tailwind"; then
echo "❌ FAIL: CSS contains uncompiled @tailwind directives"
echo "CSS content: $CSS_CONTENT"
exit 1
elif echo "$CSS_CONTENT" | grep -q "tw-border-spacing"; then
echo "✅ PASS: CSS is properly compiled with Tailwind"
echo "CSS preview: $CSS_CONTENT"
exit 0
else
echo "⚠️ UNKNOWN: Unexpected CSS content"
echo "CSS content: $CSS_CONTENT"
exit 2
fi
Technical Details
Tailwind CSS Compilation Process
-
Without config files (broken):
Source: app/globals.css ↓ @tailwind base; @tailwind components; @tailwind utilities; ↓ [NO PROCESSING - config files missing] ↓ Output: Same raw directives (27KB) ↓ Browser: ❌ Cannot interpret @tailwind directives -
With config files (fixed):
Source: app/globals.css ↓ @tailwind base; @tailwind components; @tailwind utilities; ↓ PostCSS + Tailwind JIT Compiler (using tailwind.config.ts + postcss.config.js) ↓ Output: Compiled CSS (60KB+ of actual rules) ↓ Browser: ✅ Fully styled page
Docker Build Context
When Docker builds an image:
- It reads
.dockerignoreto determine which files to exclude - It copies the remaining files into the build context
- Next.js build runs
npm run build - Next.js looks for
postcss.config.jsandtailwind.config.ts - If found: Tailwind compiles CSS ✅
- If missing: Raw CSS copied as-is ❌
Related Files
Configuration Files (MUST be in Docker build context)
- ✅
apps/frontend/postcss.config.js- Tells Next.js to use Tailwind - ✅
apps/frontend/tailwind.config.ts- Tailwind configuration - ✅
apps/frontend/app/globals.css- Source CSS with @tailwind directives
Build Files
apps/frontend/Dockerfile- Frontend Docker buildapps/frontend/.dockerignore- CRITICAL: Must not exclude config files.github/workflows/ci.yml- CI/CD pipeline (uses apps/frontend context)docker/portainer-stack.yml- Production deployment stack
Testing Files
docker-compose.dev.yml- Local testing stack (Mac ARM64)
Lessons Learned
-
Never exclude build tool configs from Docker:
- PostCSS/Tailwind configs must be in build context
- Same applies to
.babelrc,tsconfig.json, etc. - Only exclude generated output, not source configs
-
Always verify CSS compilation in Docker:
- Check actual CSS content, not just "build succeeded"
- Compare file sizes (27KB raw vs 60KB compiled)
- Test in a real browser, not just curl
-
Docker build ≠ Local build:
- Local
node_modules/has all files - Docker only has files not in
.dockerignore - Always test Docker builds locally before deploying
- Local
Commit Reference
- Commit:
88f0cc9- fix: enable Tailwind CSS compilation in Docker builds - Branch:
preprod - Date: 2025-11-19
- Files Changed:
apps/frontend/.dockerignoreapps/backend/Dockerfileapps/backend/src/application/controllers/admin/csv-rates.controller.tsdocker-compose.dev.yml
Rollback Plan
If this fix causes issues in production:
# Revert the commit
git revert 88f0cc9
# Or manually restore .dockerignore
git show 2505a36:apps/frontend/.dockerignore > apps/frontend/.dockerignore
# Push to trigger rebuild
git push origin preprod
Note: This would restore the broken CSS, so only do this if the fix causes new issues.
Future Improvements
-
Add CSS compilation check to CI/CD:
- name: Verify CSS compilation run: | docker run --rm $IMAGE_NAME sh -c \ "find .next/static/css -name '*.css' -exec grep -q '@tailwind' {} \; && exit 1 || exit 0" -
Document required Docker build context files:
- Create
apps/frontend/DOCKER_REQUIRED_FILES.md - List all files needed for successful builds
- Create
-
Add frontend healthcheck that verifies CSS:
- Create
/api/health/cssendpoint - Check that CSS files are properly compiled
- Fail container startup if CSS is broken
- Create