diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c799bf7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,14 @@ +node_modules +dist +dist-ssr +.env +.env.* +*.log +.git +.gitignore +.vscode +.idea +README.md +scripts +docker-compose.yml +.gitlab-ci.yml diff --git a/Dockerfile b/Dockerfile index 805bc02..e473dc1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,27 @@ -# Étape 1 : Build (On passe de 18 à 22) +# Étape 1 : Build FROM node:22-alpine AS build WORKDIR /app COPY package*.json ./ -# On installe les dépendances -RUN npm install +# On installe les dépendances (reproductible via le lock file) +RUN npm ci COPY . . # On récupère la variable VITE_API_URL injectée par Coolify pendant le build ARG VITE_API_URL ENV VITE_API_URL=$VITE_API_URL -# On lance le build (en ignorant les erreurs TypeScript si tu as modifié le package.json comme convenu) +# On lance le build RUN npm run build # Étape 2 : Serveur léger FROM nginx:alpine +COPY nginx.conf /etc/nginx/conf.d/default.conf COPY --from=build /app/dist /usr/share/nginx/html EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file + +# Vérifie que nginx répond bien sur le port 80 +# (127.0.0.1 et pas localhost : busybox wget résoudrait localhost en IPv6) +HEALTHCHECK --interval=30s --timeout=5s --retries=3 \ + CMD wget -q --spider http://127.0.0.1 || exit 1 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..908678f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +services: + frontend: + build: + context: . + dockerfile: Dockerfile + args: + # URL publique de l'API, définie dans les variables d'environnement Coolify + - VITE_API_URL=${VITE_API_URL:-http://localhost:3001} + container_name: logai-frontend + restart: unless-stopped + ports: + # Port du conteneur UNIQUEMENT : Coolify lui attribue automatiquement + # un port hôte et route le domaine configuré dessus. + # Ne PAS écrire "80:80" : le port 80 de l'hôte est déjà pris + # par le reverse proxy Coolify, ce qui empêcherait le conteneur de démarrer. + - "80" diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..ecad046 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,22 @@ +server { + listen 80; + listen [::]:80; + server_name _; + root /usr/share/nginx/html; + index index.html; + + # SPA (react-router BrowserRouter) : toute route inconnue renvoie index.html + # Sans ça, un rafraîchissement ou un lien direct vers /login, /logs, etc. renvoie 404. + location / { + try_files $uri $uri/ /index.html; + } + + # Assets hashés par Vite : cache immuable d'un an + location /assets/ { + add_header Cache-Control "public, max-age=31536000, immutable"; + } + + gzip on; + gzip_types text/plain text/css application/javascript application/json image/svg+xml; + gzip_min_length 1024; +} diff --git a/package-lock.json b/package-lock.json index ba7355e..e61b474 100644 --- a/package-lock.json +++ b/package-lock.json @@ -78,7 +78,6 @@ "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", @@ -288,6 +287,40 @@ "node": ">=6.9.0" } }, + "node_modules/@emnapi/core": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.3.tgz", + "integrity": "sha512-zLpS5asjEb7lq8jYLq37N6XKaE41DIexlY1rF/z4/tIl3wo13Sqm28fRyfIsKZD+NZ8mM5RoKkpW/rBcuoSZSg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.2.3", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.3.tgz", + "integrity": "sha512-ELEBe8PsLvvJ6QMr0zLt8ffvOHW/dc1m3CEzNMg7aJUv3bMaoDtw2TXyDAwkYBuroxxuHEwhRTLJSe5sya547g==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", + "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@emnapi/wasi-threads": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz", @@ -2053,7 +2086,6 @@ "integrity": "sha512-A1sre26ke7HDIuY/M23nd9gfB+nrmhtYyMINbjI1zHJxYteKR6qSMX56FsmjMcDb3SMcjJg5BiRRgOCC/yBD0g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "undici-types": "~7.16.0" } @@ -2063,7 +2095,6 @@ "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz", "integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==", "license": "MIT", - "peer": true, "dependencies": { "csstype": "^3.2.2" } @@ -2074,7 +2105,6 @@ "integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==", "devOptional": true, "license": "MIT", - "peer": true, "peerDependencies": { "@types/react": "^19.2.0" } @@ -2130,7 +2160,6 @@ "integrity": "sha512-gGkiNMPqerb2cJSVcruigx9eHBlLG14fSdPdqMoOcBfh+vvn4iCq2C8MzUB89PrxOXk0y3GZ1yIWb9aOzL93bw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.58.1", "@typescript-eslint/types": "8.58.1", @@ -2419,7 +2448,6 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2587,7 +2615,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.10.12", "caniuse-lite": "^1.0.30001782", @@ -2958,7 +2985,6 @@ "integrity": "sha512-XoMjdBOwe/esVgEvLmNsD3IRHkm7fbKIUGvrleloJXUZgDHig2IPWNniv+GwjyJXzuNqVjlr5+4yVUZjycJwfQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -5097,7 +5123,6 @@ "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -5125,7 +5150,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", @@ -5177,7 +5201,6 @@ "resolved": "https://registry.npmjs.org/react/-/react-19.2.5.tgz", "integrity": "sha512-llUJLzz1zTUBrskt2pwZgLq59AemifIftw4aB7JxOqf1HY2FDaGDxgwpAPVzHU1kdWabH7FauP4i1oEeer2WCA==", "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -5187,7 +5210,6 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.5.tgz", "integrity": "sha512-J5bAZz+DXMMwW/wV3xzKke59Af6CHY7G4uYLN1OvBcKEsWOs4pQExj86BBKamxl/Ik5bx9whOrvBlSDfWzgSag==", "license": "MIT", - "peer": true, "dependencies": { "scheduler": "^0.27.0" }, @@ -5626,8 +5648,7 @@ "version": "4.2.2", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.2.2.tgz", "integrity": "sha512-KWBIxs1Xb6NoLdMVqhbhgwZf2PGBpPEiwOqgI4pFIYbNTfBXiKYyWoTsXgBQ9WFg/OlhnvHaY+AEpW7wSmFo2Q==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/tailwindcss-animate": { "version": "1.0.7", @@ -5727,7 +5748,6 @@ "integrity": "sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -5986,7 +6006,6 @@ "integrity": "sha512-dbU7/iLVa8KZALJyLOBOQ88nOXtNG8vxKuOT4I2mD+Ya70KPceF4IAmDsmU0h1Qsn5bPrvsY9HJstCRh3hG6Uw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "lightningcss": "^1.32.0", "picomatch": "^4.0.4", @@ -6150,7 +6169,6 @@ "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==", "dev": true, "license": "MIT", - "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/src/components/SettingsModal.tsx b/src/components/SettingsModal.tsx index 13c40d6..ac58279 100644 --- a/src/components/SettingsModal.tsx +++ b/src/components/SettingsModal.tsx @@ -17,15 +17,27 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select" -import { CheckCircle2, Cpu, Globe, Link as LinkIcon } from 'lucide-react'; +import { CheckCircle2, Cloud, Cpu, Globe, Link as LinkIcon } from 'lucide-react'; + +const REMOTE_MODEL_PLACEHOLDERS: Record = { + mistral: 'ex: mistral-large-latest, mistral-small-latest', + openai: 'ex: gpt-4o, gpt-4o-mini', + claude: 'ex: claude-sonnet-4-5, claude-opus-4-1', + gemini: 'ex: gemini-2.0-flash, gemini-2.5-pro' +}; export default function SettingsModal({ onClose }: { onClose: () => void }) { const [formData, setFormData] = useState({ notionToken: '', notionDbId: '', + aiMode: 'local' as 'local' | 'remote', ollamaUrl: '', ollamaModel: '', searxngUrl: '', + remoteProvider: 'mistral', + remoteApiKey: '', + remoteModel: '', + remoteApiUrl: '', aiLanguage: 'Français' }); const [saved, setSaved] = useState(false); @@ -40,9 +52,14 @@ export default function SettingsModal({ onClose }: { onClose: () => void }) { setFormData({ notionToken: data.notionToken || '', notionDbId: data.notionDbId || '', + aiMode: data.aiMode || 'local', ollamaUrl: data.ollamaUrl || '', ollamaModel: data.ollamaModel || '', searxngUrl: data.searxngUrl || '', + remoteProvider: data.remoteProvider || 'mistral', + remoteApiKey: data.remoteApiKey || '', + remoteModel: data.remoteModel || '', + remoteApiUrl: data.remoteApiUrl || '', aiLanguage: data.aiLanguage || 'Français' }); } @@ -74,7 +91,7 @@ export default function SettingsModal({ onClose }: { onClose: () => void }) { Paramètres Globaux - Configurez vos intégrations Notion, Ollama et SearXNG pour personnaliser votre expérience LogAI. + Configurez vos intégrations Notion, votre IA (locale ou distante) et SearXNG pour personnaliser votre expérience LogAI. @@ -112,30 +129,102 @@ export default function SettingsModal({ onClose }: { onClose: () => void }) { {/* AI Integration */}
- -

Intégration IA (Ollama Local)

+ {formData.aiMode === 'remote' ? : } +

Intégration IA

+ {/* Choix du mode : local (Ollama + SearXNG) ou distant (clé API) */}
- - setFormData({...formData, ollamaUrl: e.target.value})} - placeholder="ex: http://localhost:11434" - /> -
-
- - setFormData({...formData, ollamaModel: e.target.value})} - placeholder="ex: qwen:7b, llama3" - /> + +
+ + {formData.aiMode === 'local' ? ( + <> +
+ + setFormData({...formData, ollamaUrl: e.target.value})} + placeholder="ex: http://localhost:11434" + /> +
+
+ + setFormData({...formData, ollamaModel: e.target.value})} + placeholder="ex: qwen:7b, llama3" + /> +
+ + ) : ( + <> +
+ + +
+
+ + setFormData({...formData, remoteApiKey: e.target.value})} + placeholder="ex: sk-..., ou clé fournie par le fournisseur" + /> +
+
+ + setFormData({...formData, remoteModel: e.target.value})} + placeholder={REMOTE_MODEL_PLACEHOLDERS[formData.remoteProvider] || ''} + /> +
+
+ + setFormData({...formData, remoteApiUrl: e.target.value})} + placeholder="Laisser vide pour l'API officielle du fournisseur" + /> +
+ + )} +