构建、部署与验收文档:Makefile、冒烟脚本、systemd/Caddy、决策与验收报告
- Makefile:web / sync-assets(go:embed 约束拷贝)/ build / linux / test / smoke / dev / vulncheck;版本信息 ldflags 注入 - scripts/smoke.sh:构建冒烟(§8.3-6)——起服务断言 SPA 资源 200 + 正确 MIME、meta 注入、安全头、私有不可见(19 项断言) - deploy:pure-note.service(沙箱加固)、每日 gc+backup 的 maint service/timer(03:00 Persistent)、Caddyfile 反代示例 - docs/decisions.md:35 条实施决策留档(D1–D35) - docs/acceptance.md:§9.3 检查单逐项证据、§13 测试组映射、 §12 里程碑门、浏览器端到端走查记录 - README.md:快速开始、测试、部署与升级/恢复 SOP
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
# Pure Note 构建与运维入口
|
||||
#
|
||||
# 常用目标:
|
||||
# make web 构建前端(npm ci + vite build → web/dist)
|
||||
# make sync-assets 拷贝 web/dist → internal/webui/dist(go:embed 约束,§8.3-1)
|
||||
# make build 全量构建(前端 + 单二进制)
|
||||
# make linux 交叉编译 linux/amd64
|
||||
# make test Go 测试 + 前端测试
|
||||
# make smoke 真实构建冒烟测试(§8.3-6)
|
||||
# make dev 双进程热重载(air + vite dev)
|
||||
# make vulncheck govulncheck
|
||||
|
||||
VERSION ?= $(shell git describe --tags --always 2>/dev/null || echo dev)
|
||||
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
|
||||
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
LDFLAGS := -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.buildDate=$(DATE)
|
||||
|
||||
.PHONY: web sync-assets build linux test smoke dev vulncheck clean
|
||||
|
||||
web:
|
||||
cd web && npm ci && npm run build
|
||||
|
||||
# go:embed 只能引用本包目录树内文件:产物必须拷进 internal/webui/dist
|
||||
sync-assets:
|
||||
rm -rf internal/webui/dist
|
||||
cp -r web/dist internal/webui/dist
|
||||
touch internal/webui/dist/.gitkeep
|
||||
|
||||
build: web sync-assets
|
||||
CGO_ENABLED=0 go build -trimpath -ldflags="$(LDFLAGS)" -o pure-note ./cmd/pure-note
|
||||
|
||||
linux: web sync-assets
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="$(LDFLAGS)" \
|
||||
-o pure-note-linux-amd64 ./cmd/pure-note
|
||||
|
||||
test:
|
||||
go vet ./...
|
||||
go test ./...
|
||||
cd web && npm test
|
||||
|
||||
# 构建冒烟(§8.3-6):真实构建 → 起服务 → 断言公开页与 script/link 资源 200 + 正确 MIME
|
||||
smoke: build
|
||||
./scripts/smoke.sh
|
||||
|
||||
dev:
|
||||
air &
|
||||
cd web && npm run dev
|
||||
|
||||
vulncheck:
|
||||
govulncheck ./...
|
||||
|
||||
clean:
|
||||
rm -f pure-note pure-note-linux-amd64
|
||||
Reference in New Issue
Block a user