Skip to content

Commit de396aa

Browse files
committed
合并 v2:Next.js 16 + Ant Design Pro + MySQL 全栈重构 (v2.0.0)
2 parents 800a07b + 12eb77f commit de396aa

71 files changed

Lines changed: 10213 additions & 4894 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# MySQL 连接(外部实例,必填)
2+
DB_HOST=127.0.0.1
3+
DB_PORT=3306
4+
DB_USER=relay
5+
DB_PASSWORD=
6+
DB_NAME=relay_monitor
7+
8+
# v1 数据一次性迁移来源(可选):指向 v1 的 data 目录,表为空时自动导入
9+
V1_DATA_DIR=./data

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ data/
66

77
# 本地工具配置
88
.claude/
9+
# v2 (Next.js)
10+
.next/
11+
.env
12+
.env.local
13+
next-env.d.ts
14+
tsconfig.tsbuildinfo

Dockerfile

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,41 @@
1-
# 中转站余额监控面板
2-
FROM node:22-alpine
1+
# 中转站余额监控面板 v2(Next.js standalone + MySQL)
2+
# ---- 构建阶段 ----------------------------------------------------------------
3+
FROM node:24-alpine AS builder
4+
5+
WORKDIR /app
6+
COPY package.json package-lock.json ./
7+
RUN npm ci
8+
9+
COPY . .
10+
# 构建期不连库(运行时才初始化 MySQL);占位值避免构建意外读到真实环境
11+
ENV DB_HOST=build-placeholder
12+
RUN npx next build
13+
14+
# ---- 运行阶段 ----------------------------------------------------------------
15+
FROM node:24-alpine
316

417
WORKDIR /app
518
ENV NODE_ENV=production \
6-
HOST=0.0.0.0 \
19+
HOSTNAME=0.0.0.0 \
720
PORT=8787
821

922
# 支持 TZ 环境变量(「今日」统计边界按此时区计算)
1023
RUN apk add --no-cache tzdata
1124

12-
COPY package.json package-lock.json ./
13-
RUN npm ci --omit=dev
25+
# standalone 产物:自带裁剪后的 node_modules 与 server.js
26+
COPY --from=builder /app/.next/standalone ./
27+
COPY --from=builder /app/.next/static ./.next/static
28+
COPY --from=builder /app/public ./public
29+
# 迁移脚本独立于 Next 构建图(防止真实凭证被文件追踪拷进产物),
30+
# 启动时链式执行:库为空且配置了 V1_DATA_DIR 才导入,幂等
31+
COPY --from=builder /app/db ./db
1432

15-
COPY . .
16-
17-
# 构建时注入 git commit,页面「关于」与侧栏显示
33+
# 构建时注入 git commit,页面「关于」显示
1834
ARG GIT_SHA=dev
1935
ENV APP_COMMIT=$GIT_SHA
2036

21-
# 运行时数据(站点凭证 / 历史 / 会话密钥)挂载到宿主机持久化
22-
VOLUME /app/data
23-
2437
EXPOSE 8787
25-
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s \
26-
CMD wget -q --spider http://127.0.0.1:8787/ || exit 1
38+
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s \
39+
CMD wget -q --spider http://127.0.0.1:8787/api/meta || exit 1
2740

28-
CMD ["node", "server.js"]
41+
CMD ["sh", "-c", "node db/migrate.js && exec node server.js"]

README.md

Lines changed: 49 additions & 77 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)