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
|
# JWT_SECRET doit être injecté via variable d'environnement au runtime
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
|
||||||
CMD wget -qO- http://localhost:3001/api/health || exit 1
|
CMD wget -qO- http://localhost:
|
||||||
|
|
||||||
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"]
|
|
||||||
@@ -34,6 +34,4 @@
|
|||||||
"@types/uuid": "^10.0.0",
|
"@types/uuid": "^10.0.0",
|
||||||
"drizzle-kit": "^0.22.7",
|
"drizzle-kit": "^0.22.7",
|
||||||
"ts-node-dev": "^2.0.0",
|
"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) ─────────────────────────────────────────────
|
// ─── Serve Frontend (production) ─────────────────────────────────────────────
|
||||||
const publicDir = path.join(__dirname, '..', 'public')
|
const publicDir = path.join(__dirname, '..', 'public')
|
||||||
if (fs.existsSync(publicDir)) {
|
if (fs.existsSync(publicDir)) {
|
||||||
app.use(express.static(publicDir))
|
// Service worker — jamais mis en cache (sinon l'ancien SW continue après déploiement)
|
||||||
app.get('*', (_req, res) => res.sendFile(path.join(publicDir, 'index.html')))
|
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'))
|
||||||
|
})
|
||||||
|
|
||||||
// ─── Start ────────────────────────────────────────────────────────────────────
|
// Manifeste PWA — pas de cache long
|
||||||
app.listen(PORT, () => {
|
app.get(/\.webmanifest$/, (_req, res, next) => {
|
||||||
console.log(`✓ ShootTracker backend → http://localhost:${PORT}`)
|
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate')
|
||||||
console.log(` Uploads : ${UPLOADS_DIR}`)
|
res.set
|
||||||
console.log(` AI : ${process.env.AI_SERVICE_URL || 'http://localhost:8000'}`)
|
|
||||||
})
|
|
||||||
@@ -168,5 +168,4 @@ exportRouter.get('/excel', (req: AuthRequest, res) => {
|
|||||||
const filename = `shoottracker_${format(new Date(), 'yyyy-MM-dd')}.xlsx`
|
const filename = `shoottracker_${format(new Date(), 'yyyy-MM-dd')}.xlsx`
|
||||||
res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
|
res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
|
||||||
res.setHeader('Content-Disposition', `attachment; filename="${filename}"`)
|
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/**/*"],
|
"include": ["src/**/*"],
|
||||||
"exclude": ["node_modules", "dist"]
|
"exclude": ["node_modules", "dist"]
|
||||||
}
|
|
||||||
|
|||||||
+1
-10
@@ -56,13 +56,4 @@ services:
|
|||||||
- yolo_models:/root/.config/Ultralytics
|
- yolo_models:/root/.config/Ultralytics
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "wget", "-qO-", "http://localhost:8000/health"]
|
test: ["CMD", "wget", "-qO-", "http://localhost:8000/health"]
|
||||||
interval: 30s
|
interval:
|
||||||
timeout: 15s
|
|
||||||
retries: 3
|
|
||||||
start_period: 60s
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
shoottracker_data:
|
|
||||||
driver: local
|
|
||||||
yolo_models:
|
|
||||||
driver: local
|
|
||||||
Binary file not shown.
@@ -25,12 +25,13 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
workbox: {
|
workbox: {
|
||||||
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
|
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
|
||||||
|
cleanupOutdatedCaches: true,
|
||||||
runtimeCaching: [
|
runtimeCaching: [
|
||||||
{
|
{
|
||||||
urlPattern: /^\/api\/.*/i,
|
urlPattern: /^\/api\/.*/i,
|
||||||
handler: 'NetworkFirst',
|
handler: 'NetworkFirst',
|
||||||
options: {
|
options: {
|
||||||
cacheName: 'api-cache',
|
cacheName: 'shoottracker-api-cache',
|
||||||
expiration: { maxEntries: 50, maxAgeSeconds: 60 * 5 },
|
expiration: { maxEntries: 50, maxAgeSeconds: 60 * 5 },
|
||||||
networkTimeoutSeconds: 10,
|
networkTimeoutSeconds: 10,
|
||||||
}
|
}
|
||||||
@@ -46,8 +47,4 @@ export default defineConfig({
|
|||||||
'/uploads': { target: 'http://localhost:3001', changeOrigin: true }
|
'/uploads': { target: 'http://localhost:3001', changeOrigin: true }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
build: {
|
build:
|
||||||
outDir: 'dist',
|
|
||||||
sourcemap: false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
Reference in New Issue
Block a user