feat: Add Docker containerization, production serving, and Gitea CI/CD workflow.
Some checks failed
Build and Deploy / build (push) Failing after 2m44s
Some checks failed
Build and Deploy / build (push) Failing after 2m44s
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
"server": "tsx watch server/index.ts",
|
||||
"client": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"start": "node server/dist/index.js"
|
||||
"start": "NODE_ENV=production tsx server/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^4.21.2",
|
||||
@@ -16,7 +16,8 @@
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0",
|
||||
"socket.io": "^4.8.1",
|
||||
"socket.io-client": "^4.8.1"
|
||||
"socket.io-client": "^4.8.1",
|
||||
"tsx": "^4.19.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^4.17.21",
|
||||
@@ -28,8 +29,7 @@
|
||||
"concurrently": "^9.1.0",
|
||||
"postcss": "^8.4.49",
|
||||
"tailwindcss": "^3.4.16",
|
||||
"tsx": "^4.19.2",
|
||||
"typescript": "^5.7.2",
|
||||
"vite": "^6.0.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,13 @@ app.get('/api/health', (_req: Request, res: Response) => {
|
||||
res.json({ status: 'ok', message: 'Server is running' });
|
||||
});
|
||||
|
||||
// Serve Frontend in Production
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
const distPath = path.resolve(process.cwd(), 'dist');
|
||||
app.use(express.static(distPath));
|
||||
|
||||
}
|
||||
|
||||
app.post('/api/cards/cache', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const { cards } = req.body;
|
||||
@@ -201,6 +208,19 @@ io.on('connection', (socket) => {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Handle Client-Side Routing (Catch-All) - Must be last
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
app.get('*', (_req: Request, res: Response) => {
|
||||
// Check if request is for API
|
||||
if (_req.path.startsWith('/api') || _req.path.startsWith('/socket.io')) {
|
||||
return res.status(404).json({ error: 'Not found' });
|
||||
}
|
||||
const distPath = path.resolve(process.cwd(), 'dist');
|
||||
res.sendFile(path.join(distPath, 'index.html'));
|
||||
});
|
||||
}
|
||||
|
||||
import os from 'os';
|
||||
|
||||
httpServer.listen(Number(PORT), '0.0.0.0', () => {
|
||||
|
||||
Reference in New Issue
Block a user