fix: corrections SW cache, nginx proxy, sw.js no-cache — 2026-05-01 05:48
This commit is contained in:
+1
-10
@@ -44,13 +44,4 @@ 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: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"]
|
||||
CMD wget -qO- http://localhost:
|
||||
@@ -34,6 +34,4 @@
|
||||
"@types/uuid": "^10.0.0",
|
||||
"drizzle-kit": "^0.22.7",
|
||||
"ts-node-dev": "^2.0.0",
|
||||
"typescript": "^5.4.5"
|
||||
}
|
||||
}
|
||||
"typescript": "^5.4
|
||||
+11
-9
@@ -47,13 +47,15 @@ app.use('/api/export', exportRouter)
|
||||
// ─── Serve Frontend (production) ─────────────────────────────────────────────
|
||||
const publicDir = path.join(__dirname, '..', 'public')
|
||||
if (fs.existsSync(publicDir)) {
|
||||
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'}`)
|
||||
// Service worker — jamais mis en cache (sinon l'ancien SW continue après déploiement)
|
||||
app.get('/sw.js', (_req, res) => {
|
||||
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate')
|
||||
res.setHeader('Pragma', 'no-cache')
|
||||
res.setHeader('Expires', '0')
|
||||
res.sendFile(path.join(publicDir, 'sw.js'))
|
||||
})
|
||||
|
||||
// Manifeste PWA — pas de cache long
|
||||
app.get(/\.webmanifest$/, (_req, res, next) => {
|
||||
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate')
|
||||
res.set
|
||||
@@ -168,5 +168,4 @@ 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: 'xlsx' }))
|
||||
})
|
||||
res.send(XLSX.write(wb, { type: 'buffer', bookType:
|
||||
@@ -16,4 +16,3 @@
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
|
||||
+1
-10
@@ -56,13 +56,4 @@ services:
|
||||
- yolo_models:/root/.config/Ultralytics
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-qO-", "http://localhost:8000/health"]
|
||||
interval: 30s
|
||||
timeout: 15s
|
||||
retries: 3
|
||||
start_period: 60s
|
||||
|
||||
volumes:
|
||||
shoottracker_data:
|
||||
driver: local
|
||||
yolo_models:
|
||||
driver: local
|
||||
interval:
|
||||
Binary file not shown.
@@ -25,12 +25,13 @@ export default defineConfig({
|
||||
},
|
||||
workbox: {
|
||||
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
|
||||
cleanupOutdatedCaches: true,
|
||||
runtimeCaching: [
|
||||
{
|
||||
urlPattern: /^\/api\/.*/i,
|
||||
handler: 'NetworkFirst',
|
||||
options: {
|
||||
cacheName: 'api-cache',
|
||||
cacheName: 'shoottracker-api-cache',
|
||||
expiration: { maxEntries: 50, maxAgeSeconds: 60 * 5 },
|
||||
networkTimeoutSeconds: 10,
|
||||
}
|
||||
@@ -46,8 +47,4 @@ export default defineConfig({
|
||||
'/uploads': { target: 'http://localhost:3001', changeOrigin: true }
|
||||
}
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
sourcemap: false
|
||||
}
|
||||
})
|
||||
build:
|
||||
Reference in New Issue
Block a user