Dockerize client, server, and postgres database for production with container healthchecks

This commit is contained in:
2026-05-28 12:23:50 +02:00
parent 9a2052f623
commit 572d38e490
10 changed files with 176 additions and 11 deletions
+19 -6
View File
@@ -4,6 +4,7 @@ import dotenv from 'dotenv'
import authRouter from './routes/auth.js'
import logbooksRouter from './routes/logbooks.js'
import syncRouter from './routes/sync.js'
import { prisma } from './db.js'
dotenv.config()
@@ -19,12 +20,24 @@ app.use('/api/logbooks', logbooksRouter)
app.use('/api/sync', syncRouter)
// Health check endpoint
app.get('/api/health', (req, res) => {
res.json({
status: 'ok',
timestamp: new Date().toISOString(),
service: 'Kapteins Daagbox Backend'
})
app.get('/api/health', async (req, res) => {
try {
await prisma.$queryRaw`SELECT 1`
res.json({
status: 'ok',
database: 'connected',
timestamp: new Date().toISOString(),
service: 'Kapteins Daagbox Backend'
})
} catch (err: any) {
res.status(500).json({
status: 'error',
database: 'disconnected',
error: err.message,
timestamp: new Date().toISOString(),
service: 'Kapteins Daagbox Backend'
})
}
})
app.listen(PORT, () => {