Add single container Docker setup (backend + frontend in one container)

This commit is contained in:
salvacybersec
2025-11-11 05:33:46 +03:00
parent c35a130091
commit 36c5b108ed
4 changed files with 223 additions and 0 deletions

View File

@@ -100,6 +100,23 @@ app.use(express.urlencoded({ extended: true }));
// Serve static files (landing page)
app.use(express.static('src/public'));
// Serve frontend build files (if exists, for production)
const path = require('path');
const frontendDistPath = path.join(__dirname, '../../frontend/dist');
const fs = require('fs');
if (fs.existsSync(frontendDistPath)) {
app.use(express.static(frontendDistPath));
// SPA fallback: serve index.html for all non-API routes
app.get('*', (req, res, next) => {
// Skip API routes and tracking routes
if (req.path.startsWith('/api') || req.path.startsWith('/t/') || req.path.startsWith('/health')) {
return next();
}
res.sendFile(path.join(frontendDistPath, 'index.html'));
});
}
// Session middleware
app.use(session(sessionConfig));