feat: 新增 Docker Compose 部署方案

- Dockerfile 单阶段 Alpine 镜像,使用国内镜像(npmmirror / Prisma 引擎 / apk)加速
- entrypoint 首次复制内置图章素材到 uploads volume,自动执行 prisma migrate deploy
- docker-compose.yml 绑定 127.0.0.1:3001,强制走外部 Nginx 反代
- Express 在 production 下同时托管 packages/web/dist 及 SPA fallback
- Prisma schema 增加 linux-musl 二进制目标,支持 Alpine 运行
- 新增 DEPLOY.md 部署指南,含 .env 模板与 Nginx 反代示例

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-19 17:04:25 +08:00
parent 0319557723
commit 711f422558
8 changed files with 307 additions and 1 deletions

View File

@@ -31,6 +31,17 @@ app.use("/api/redemption", redemptionRoutes);
// Admin routes
app.use("/api/admin", adminRoutes);
// Serve built web frontend in production (single-container deployment)
if (process.env.NODE_ENV === "production") {
const webDist = path.join(__dirname, "../../web/dist");
app.use(express.static(webDist));
app.use((req, res, next) => {
if (req.method !== "GET" && req.method !== "HEAD") return next();
if (req.path.startsWith("/api") || req.path.startsWith("/uploads")) return next();
res.sendFile(path.join(webDist, "index.html"));
});
}
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
});