diff --git a/Dockerfile b/Dockerfile index 70010a5..bb173d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,4 +44,13 @@ ENV PORT=3001 # JWT_SECRET doit être injecté via variable d'environnement au runtime HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \ - CMD wget -qO- http://localhost: \ No newline at end of file + CMD wget -qO- http://localhost:3001/api/health || exit 1 + +EXPOSE 3001 + +# Volume pour SQLite DB + uploads (persistant entre les redémarrages) +VOLUME ["/app/data"] + +# ts-node --transpile-only : contourne les erreurs de compilation tsc +# (dist/index.js produit par tsc est tronqué sur certains environnements Alpine) +CMD ["node_modules/.bin/ts-node", "--transpile-only", "src/index.ts"] diff --git a/backend/package.json b/backend/package.json index 1a52f02..a66a735 100644 --- a/backend/package.json +++ b/backend/package.json @@ -34,4 +34,6 @@ "@types/uuid": "^10.0.0", "drizzle-kit": "^0.22.7", "ts-node-dev": "^2.0.0", - "typescript": "^5.4 \ No newline at end of file + "typescript": "^5.4.5" + } +} diff --git a/backend/src/index.ts b/backend/src/index.ts index 429aa4f..575895b 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -58,4 +58,17 @@ if (fs.existsSync(publicDir)) { // Manifeste PWA — pas de cache long app.get(/\.webmanifest$/, (_req, res, next) => { res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate') - res.set \ No newline at end of file + res.setHeader('Expires', '0') + next() + }) + + app.use(express.static(publicDir)) + app.get('*', (_req, res) => res.sendFile(path.join(publicDir, 'index.html'))) +} + +// ─── Start ──────────────────────────────────────────────────────────────────── +app.listen(PORT, () => { + console.log(`✓ ShootTracker backend → http://localhost:${PORT}`) + console.log(` Uploads : ${UPLOADS_DIR}`) + console.log(` AI : ${process.env.AI_SERVICE_URL || 'http://localhost:8000'}`) +}) diff --git a/backend/src/routes/export.ts b/backend/src/routes/export.ts index 9e9a2fb..b58f384 100644 --- a/backend/src/routes/export.ts +++ b/backend/src/routes/export.ts @@ -168,4 +168,5 @@ exportRouter.get('/excel', (req: AuthRequest, res) => { const filename = `shoottracker_${format(new Date(), 'yyyy-MM-dd')}.xlsx` res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') res.setHeader('Content-Disposition', `attachment; filename="${filename}"`) - res.send(XLSX.write(wb, { type: 'buffer', bookType: \ No newline at end of file + res.send(XLSX.write(wb, { type: 'buffer', bookType: 'xlsx' })) +}) diff --git a/backend/tsconfig.json b/backend/tsconfig.json index dbf3fd5..8b918f5 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -16,3 +16,4 @@ }, "include": ["src/**/*"], "exclude": ["node_modules", "dist"] +} diff --git a/docker-compose.yml b/docker-compose.yml index ddd2cec..904fdc0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -56,4 +56,13 @@ services: - yolo_models:/root/.config/Ultralytics healthcheck: test: ["CMD", "wget", "-qO-", "http://localhost:8000/health"] - interval: \ No newline at end of file + interval: 30s + timeout: 15s + retries: 3 + start_period: 60s + +volumes: + shoottracker_data: + driver: local + yolo_models: + driver: local diff --git a/frontend/package.json b/frontend/package.json index 643fbdb..afec696 100644 Binary files a/frontend/package.json and b/frontend/package.json differ diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 448279a..ec23fc9 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -47,4 +47,8 @@ export default defineConfig({ '/uploads': { target: 'http://localhost:3001', changeOrigin: true } } }, - build: \ No newline at end of file + build: { + outDir: 'dist', + sourcemap: false + } +})