Update README and server configuration for VPS Tracker application
Docker / build (push) Failing after 2m55s
Docker / build (push) Failing after 2m55s
- Renamed project from "React + Vite" to "VPS Tracker" and updated the README to reflect the application's purpose and usage instructions. - Added detailed Docker setup instructions, including two methods for running the application: using Docker Compose and standalone Docker. - Implemented static file serving in the server configuration to serve the frontend from the 'dist' directory if it exists, enhancing the application's deployment capabilities.
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import express from 'express'
|
||||
import cors from 'cors'
|
||||
import { existsSync } from 'fs'
|
||||
import { dirname, join } from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
import { initDb } from './db.js'
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
const distPath = join(__dirname, '..', 'dist')
|
||||
import dataRouter from './routes/data.js'
|
||||
import migrateRouter from './routes/migrate.js'
|
||||
import vpsRouter from './routes/vps.js'
|
||||
@@ -34,6 +40,14 @@ app.use(express.json({ limit: '50mb' }))
|
||||
app.use('/api/projects', projectsRouter)
|
||||
app.use('/api/backup', backupRouter)
|
||||
|
||||
if (existsSync(distPath)) {
|
||||
app.use(express.static(distPath))
|
||||
app.get(/.*/, (req, res, next) => {
|
||||
if (req.path.startsWith('/api')) return next()
|
||||
res.sendFile(join(distPath, 'index.html'), (err) => (err ? next(err) : undefined))
|
||||
})
|
||||
}
|
||||
|
||||
const { startScheduler } = await import('./sync-scheduler.js')
|
||||
startScheduler()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user