feat(storage): move project data to SQLite via node:sqlite

- server/db.mjs: schema (site + projects), transactional replace, WAL, VACUUM INTO backups (keep 10), JSON export, first-run seed from data/projects.json
- publish.mjs: read/write through the database, export mirror JSON for git/static/offline, validate duplicate project_id
- ui/data.js: read live data from /api/projects first, fall back to data/projects.json
- Dockerfile/compose/.env.example: DB_PATH, drop experimental sqlite warning flag
- docs: AGENTS.md + README describe the database layer and traps
This commit is contained in:
Bkk1234 committed 2026-11-23 00:24:47 +07:00
1 parent 830dba58ec
commit 5fb095b872
11 files changed
+364 -61

No files matched your search

+4 -2
View File
@@ -1,4 +1,5 @@
# hobbypj-contents — เพจรายชื่อโปรเจค + หลังบ้าน (Node stdlib ล้วน ไม่มี dependency)
# ต้อง Node ≥ 22.13 เพราะใช้ node:sqlite โดยไม่ต้องใส่ flag
FROM node:22-alpine
# ต้องมี git เพราะ server/publish.mjs ใช้ commit + push ข้อมูลขึ้น Gitea
@@ -20,7 +21,8 @@ COPY --chown=node:node config/ ./config/
ENV NODE_ENV=production \
PORT=8090 \
HOST=0.0.0.0 \
PUBLISH_PUSH=0
PUBLISH_PUSH=0 \
DB_PATH=data/hobbypj.sqlite
USER node
EXPOSE 8090
@@ -28,4 +30,4 @@ EXPOSE 8090
# ไม่ใส่ HEALTHCHECK: OCI format ของ podman ไม่รับ และ WSL ไม่มี systemd ให้ timer
# ตรวจสุขภาพเองด้วย: curl -fsS http://127.0.0.1:8090/api/projects
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "server/publish.mjs"]
CMD ["node", "--disable-warning=ExperimentalWarning", "server/publish.mjs"]