speccore 8.3.290 → 8.3.296
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +16 -3
- package/README.md +9 -7
- package/dist/cli.js +11 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/about.d.ts.map +1 -1
- package/dist/commands/about.js +5 -0
- package/dist/commands/about.js.map +1 -1
- package/dist/commands/analyze.d.ts.map +1 -1
- package/dist/commands/analyze.js +77 -5
- package/dist/commands/analyze.js.map +1 -1
- package/dist/commands/ask.js +2 -2
- package/dist/commands/ask.js.map +1 -1
- package/dist/commands/execute.js +1 -0
- package/dist/commands/execute.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +25 -4
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/iteration/taskify.d.ts.map +1 -1
- package/dist/commands/iteration/taskify.js +132 -7
- package/dist/commands/iteration/taskify.js.map +1 -1
- package/dist/commands/status-panel.d.ts +1 -0
- package/dist/commands/status-panel.d.ts.map +1 -1
- package/dist/commands/status-panel.js +65 -17
- package/dist/commands/status-panel.js.map +1 -1
- package/dist/commands/update-env-configs.d.ts.map +1 -1
- package/dist/commands/update-env-configs.js +6 -0
- package/dist/commands/update-env-configs.js.map +1 -1
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +78 -1
- package/dist/commands/verify.js.map +1 -1
- package/dist/core/deploy/engine.d.ts +11 -0
- package/dist/core/deploy/engine.d.ts.map +1 -1
- package/dist/core/deploy/engine.js +35 -7
- package/dist/core/deploy/engine.js.map +1 -1
- package/dist/core/git-integration.d.ts +2 -1
- package/dist/core/git-integration.d.ts.map +1 -1
- package/dist/core/git-integration.js +38 -14
- package/dist/core/git-integration.js.map +1 -1
- package/dist/core/global-counters.d.ts +3 -0
- package/dist/core/global-counters.d.ts.map +1 -1
- package/dist/core/global-counters.js +3 -1
- package/dist/core/global-counters.js.map +1 -1
- package/dist/core/prompt-builder.d.ts.map +1 -1
- package/dist/core/prompt-builder.js +7 -6
- package/dist/core/prompt-builder.js.map +1 -1
- package/dist/core/spec-paths.d.ts.map +1 -1
- package/dist/core/spec-paths.js +3 -0
- package/dist/core/spec-paths.js.map +1 -1
- package/dist/core/spec-skeleton.d.ts.map +1 -1
- package/dist/core/spec-skeleton.js +6 -2
- package/dist/core/spec-skeleton.js.map +1 -1
- package/dist/core/state.d.ts +11 -0
- package/dist/core/state.d.ts.map +1 -1
- package/dist/core/state.js +33 -2
- package/dist/core/state.js.map +1 -1
- package/dist/core/ui-verify/index.d.ts +2 -2
- package/dist/core/ui-verify/index.d.ts.map +1 -1
- package/dist/core/ui-verify/index.js +3 -1
- package/dist/core/ui-verify/index.js.map +1 -1
- package/dist/core/ui-verify/smoke-engine.d.ts.map +1 -1
- package/dist/core/ui-verify/smoke-engine.js +36 -0
- package/dist/core/ui-verify/smoke-engine.js.map +1 -1
- package/dist/core/ui-verify/spec-generator.d.ts +32 -1
- package/dist/core/ui-verify/spec-generator.d.ts.map +1 -1
- package/dist/core/ui-verify/spec-generator.js +205 -21
- package/dist/core/ui-verify/spec-generator.js.map +1 -1
- package/dist/core/ui-verify/types.d.ts +2 -0
- package/dist/core/ui-verify/types.d.ts.map +1 -1
- package/package.json +3 -2
- package/templates/api-design-example.md +338 -0
- package/templates/ci/github-actions.yml +44 -0
- package/templates/database-example.md +223 -0
- package/templates/deploy-docker/README.md +296 -0
- package/templates/deploy-docker/backend-node.Dockerfile +52 -0
- package/templates/deploy-docker/deploy-remote.sh +79 -0
- package/templates/deploy-docker/docker-compose.yml +113 -0
- package/templates/deploy-docker/frontend.Dockerfile +43 -0
- package/templates/deploy-docker/nginx.conf +30 -0
- package/templates/deploy-examples.yaml +511 -0
- package/templates/deploy-java/Dockerfile +50 -0
- package/templates/deploy-java/README.md +212 -0
- package/templates/deploy-java/deploy.sh +120 -0
- package/templates/deploy-java/spring-boot.service +35 -0
- package/templates/deploy-nginx/README.md +59 -0
- package/templates/deploy-nginx/nginx-site.conf +103 -0
- package/templates/deploy-scripts/README.md +61 -0
- package/templates/deploy-scripts/deploy-compose.sh +19 -0
- package/templates/deploy-scripts/deploy-ftp.sh +28 -0
- package/templates/deploy-scripts/deploy-password-ssh.sh +26 -0
- package/templates/deploy-scripts/deploy-python.sh +30 -0
- package/templates/deploy-scripts/trigger-jenkins.sh +30 -0
- package/templates/html/speccore-ask-explain.html +10 -0
- package/templates/html/speccore-ask-guide.html +10 -0
- package/templates/html/speccore-ask-match.html +10 -0
- package/templates/html/speccore-ask-pipeline.html +1 -0
- package/templates/html/speccore-ask-result.html +10 -0
- package/templates/html/speccore-help.html +241 -0
- package/templates/html/speccore-setup-guide.html +289 -0
- package/templates/security-example.md +226 -0
- package/templates/speccore-yml-example.yml +222 -0
- package/templates/verify-spec-example.yaml +142 -0
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
# ═══════════════════════════════════════════════════════════
|
|
2
|
+
# SpecCore 部署配置示例(v8.3.91+)
|
|
3
|
+
# ═══════════════════════════════════════════════════════════
|
|
4
|
+
#
|
|
5
|
+
# 使用方式:
|
|
6
|
+
# 1. 复制你需要的配置块到 PROJECT.yaml 的 platform.deploy 段
|
|
7
|
+
# 2. 或复制到 .speccore/environments/{env}.yaml 的 platform 段
|
|
8
|
+
#
|
|
9
|
+
# 部署命令:
|
|
10
|
+
# speccore deploy --env staging --platform <端名>
|
|
11
|
+
# speccore deploy --env staging --all
|
|
12
|
+
# speccore deploy --env production --platform h5 --dry-run # 预览模式
|
|
13
|
+
#
|
|
14
|
+
# ═══════════════════════════════════════════════════════════
|
|
15
|
+
|
|
16
|
+
# ─────────────────────────────────────────
|
|
17
|
+
# 1. SSH 部署(推荐:有独立服务器的场景)
|
|
18
|
+
# ─────────────────────────────────────────
|
|
19
|
+
#
|
|
20
|
+
# 适用场景:前端构建后上传到 Nginx/Apache 静态目录,或后端上传到服务器重启
|
|
21
|
+
#
|
|
22
|
+
# 认证方式:
|
|
23
|
+
# 方式 A — 密钥认证(推荐,更安全):
|
|
24
|
+
# 1) 本地生成密钥:ssh-keygen -t rsa -b 4096
|
|
25
|
+
# 2) 上传公钥到服务器:ssh-copy-id -i ~/.ssh/id_rsa.pub user@host
|
|
26
|
+
# 3) 配置 key 字段指向私钥路径
|
|
27
|
+
#
|
|
28
|
+
# 方式 B — 密码认证(v8.3.91+):
|
|
29
|
+
# 1) 安装 sshpass:
|
|
30
|
+
# macOS: brew install sshpass
|
|
31
|
+
# Ubuntu/Debian: apt-get install sshpass
|
|
32
|
+
# 2) 配置 password 字段
|
|
33
|
+
#
|
|
34
|
+
ssh_key_example:
|
|
35
|
+
type: ssh
|
|
36
|
+
build_cmd: npm run build:staging
|
|
37
|
+
output_dir: dist
|
|
38
|
+
host: deployer@192.168.1.100:22
|
|
39
|
+
key: ~/.ssh/id_rsa
|
|
40
|
+
remote_dir: /var/www/html/h5
|
|
41
|
+
script: sudo nginx -s reload
|
|
42
|
+
pre_deploy:
|
|
43
|
+
- echo "开始部署到 staging..."
|
|
44
|
+
post_deploy:
|
|
45
|
+
- echo "部署完成"
|
|
46
|
+
|
|
47
|
+
# SSH 密码认证示例
|
|
48
|
+
ssh_password_example:
|
|
49
|
+
type: ssh
|
|
50
|
+
build_cmd: npm run build:staging
|
|
51
|
+
output_dir: dist
|
|
52
|
+
host: deployer@192.168.1.100:22
|
|
53
|
+
password: your-password-here # SSH 密码(v8.3.91+,需安装 sshpass)
|
|
54
|
+
remote_dir: /var/www/html/h5
|
|
55
|
+
script: sudo nginx -s reload
|
|
56
|
+
|
|
57
|
+
# ─────────────────────────────────────────
|
|
58
|
+
# 2. SFTP 部署(无 SSH 权限,只有 SFTP)
|
|
59
|
+
# ─────────────────────────────────────────
|
|
60
|
+
#
|
|
61
|
+
# 适用场景:共享主机、虚拟主机,只有 SFTP 权限无 SSH 登录权限
|
|
62
|
+
#
|
|
63
|
+
sftp_example:
|
|
64
|
+
type: sftp
|
|
65
|
+
build_cmd: npm run build
|
|
66
|
+
output_dir: dist
|
|
67
|
+
host: deployer@192.168.1.100 # SFTP 地址(格式 user@host)
|
|
68
|
+
key: ~/.ssh/id_rsa # SSH 私钥路径
|
|
69
|
+
remote_dir: /var/www/html/h5 # 远程目录(SFTP 必须有写权限)
|
|
70
|
+
|
|
71
|
+
# ─────────────────────────────────────────
|
|
72
|
+
# 3. 静态资源部署(local / S3 / rsync)
|
|
73
|
+
# ─────────────────────────────────────────
|
|
74
|
+
#
|
|
75
|
+
# 适用场景:CDN、对象存储、共享文件系统、本地目录
|
|
76
|
+
#
|
|
77
|
+
# target 格式:
|
|
78
|
+
# - 本地路径:/var/www/html/h5
|
|
79
|
+
# - S3 桶:s3://my-bucket/h5/
|
|
80
|
+
# - rsync 远程:rsync://user@host:/var/www/html/h5
|
|
81
|
+
# - rsync 远程(简写):user@host:/var/www/html/h5
|
|
82
|
+
#
|
|
83
|
+
static_local_example:
|
|
84
|
+
type: static
|
|
85
|
+
build_cmd: npm run build
|
|
86
|
+
output_dir: dist
|
|
87
|
+
target: /var/www/html/h5 # 本地或挂载的共享目录
|
|
88
|
+
|
|
89
|
+
static_s3_example:
|
|
90
|
+
type: static
|
|
91
|
+
build_cmd: npm run build
|
|
92
|
+
output_dir: dist
|
|
93
|
+
target: s3://my-cdn-bucket/h5-staging/ # AWS S3(需安装 AWS CLI)
|
|
94
|
+
|
|
95
|
+
static_rsync_example:
|
|
96
|
+
type: static
|
|
97
|
+
build_cmd: npm run build
|
|
98
|
+
output_dir: dist
|
|
99
|
+
target: deployer@cdn-server:/var/www/html/h5 # rsync 远程同步
|
|
100
|
+
|
|
101
|
+
# ─────────────────────────────────────────
|
|
102
|
+
# 4. 自定义脚本部署(最灵活)
|
|
103
|
+
# ─────────────────────────────────────────
|
|
104
|
+
#
|
|
105
|
+
# 适用场景:Jenkins 触发、FTP 上传、复杂部署流程
|
|
106
|
+
#
|
|
107
|
+
# script 字段可以是:
|
|
108
|
+
# - 脚本文件路径(相对于 code_path):./scripts/deploy-staging.sh
|
|
109
|
+
# - 直接命令:curl -X POST http://jenkins/job/build/build
|
|
110
|
+
#
|
|
111
|
+
script_jenkins_example:
|
|
112
|
+
type: script
|
|
113
|
+
build_cmd: npm run build
|
|
114
|
+
script: ./scripts/trigger-jenkins.sh # 脚本文件(存在则执行 bash)
|
|
115
|
+
# 或直接写命令:
|
|
116
|
+
# script: "curl -X POST -u user:token http://jenkins.example.com/job/my-job/build"
|
|
117
|
+
|
|
118
|
+
script_ftp_example:
|
|
119
|
+
type: script
|
|
120
|
+
build_cmd: npm run build
|
|
121
|
+
output_dir: dist
|
|
122
|
+
script: ./scripts/deploy-ftp.sh # 脚本内容示例见下文
|
|
123
|
+
|
|
124
|
+
# ─────────────────────────────────────────
|
|
125
|
+
# 5. Docker 部署
|
|
126
|
+
# ─────────────────────────────────────────
|
|
127
|
+
#
|
|
128
|
+
# 适用场景:容器化部署,支持本地构建 + 镜像仓库推送 + 远程服务器部署
|
|
129
|
+
#
|
|
130
|
+
# 远程部署说明(v8.3.96+):
|
|
131
|
+
# - 配置 host 后,speccore 会自动 SSH 到远程服务器执行 docker pull && run
|
|
132
|
+
# - 远程部署必须配置 registry(否则远程服务器无法获取镜像)
|
|
133
|
+
# - 可通过 script 字段自定义远程命令(默认:stop → rm → pull → run)
|
|
134
|
+
# - 支持密钥认证(key)和密码认证(password + sshpass)
|
|
135
|
+
#
|
|
136
|
+
# 完整模板见 templates/deploy-docker/(含前端 Dockerfile、Nginx 配置、Compose 编排)
|
|
137
|
+
|
|
138
|
+
# 基础 Docker:仅本地构建并推送到仓库(适合 CI/CD 场景)
|
|
139
|
+
docker_push_only:
|
|
140
|
+
type: docker
|
|
141
|
+
dockerfile: ./Dockerfile
|
|
142
|
+
registry: registry.example.com
|
|
143
|
+
image: my-project/h5
|
|
144
|
+
tag: staging
|
|
145
|
+
|
|
146
|
+
# 前端 Docker + 远程部署(Nginx 托管)
|
|
147
|
+
docker_frontend_remote:
|
|
148
|
+
type: docker
|
|
149
|
+
build_cmd: npm run build:staging # 前置构建(可选)
|
|
150
|
+
dockerfile: ./Dockerfile # 多阶段构建:Node → Nginx
|
|
151
|
+
registry: registry.example.com
|
|
152
|
+
image: my-project/admin-web
|
|
153
|
+
tag: staging
|
|
154
|
+
host: deployer@staging-server.example.com # 远程服务器(v8.3.96+)
|
|
155
|
+
key: ~/.ssh/id_rsa
|
|
156
|
+
# script 自定义远程命令(可选,以下为默认值示例)
|
|
157
|
+
# script: "docker pull registry.example.com/my-project/admin-web:staging && docker stop admin-web 2>/dev/null; docker rm admin-web 2>/dev/null; docker run -d --name admin-web --restart always -p 80:80 registry.example.com/my-project/admin-web:staging"
|
|
158
|
+
|
|
159
|
+
# 后端 Java Docker + 远程部署
|
|
160
|
+
docker_backend_remote:
|
|
161
|
+
type: docker
|
|
162
|
+
dockerfile: ./Dockerfile # 多阶段构建:Maven → JRE
|
|
163
|
+
registry: registry.example.com
|
|
164
|
+
image: my-project/order-service
|
|
165
|
+
tag: staging
|
|
166
|
+
host: deployer@staging-server.example.com
|
|
167
|
+
key: ~/.ssh/id_rsa
|
|
168
|
+
|
|
169
|
+
# Docker Compose 统一部署(使用 script 类型调用 compose)
|
|
170
|
+
docker_compose_example:
|
|
171
|
+
type: script
|
|
172
|
+
script: ./scripts/deploy-compose.sh
|
|
173
|
+
# deploy-compose.sh 内容示例:
|
|
174
|
+
# cd /opt/deploy && docker-compose pull && docker-compose up -d
|
|
175
|
+
|
|
176
|
+
# ─────────────────────────────────────────
|
|
177
|
+
# 6. PM2 部署(Node.js 后端)
|
|
178
|
+
# ─────────────────────────────────────────
|
|
179
|
+
#
|
|
180
|
+
# 适用场景:Node.js 服务,本地或远程 PM2 进程管理
|
|
181
|
+
#
|
|
182
|
+
pm2_local_example:
|
|
183
|
+
type: pm2
|
|
184
|
+
build_cmd: npm run build
|
|
185
|
+
output_dir: .
|
|
186
|
+
pm2_config: ecosystem.config.js # PM2 配置文件(默认 ecosystem.config.js)
|
|
187
|
+
|
|
188
|
+
pm2_remote_example:
|
|
189
|
+
type: pm2
|
|
190
|
+
build_cmd: npm run build
|
|
191
|
+
pm2_config: ecosystem.config.js
|
|
192
|
+
host: deployer@192.168.1.100 # 远程服务器(可选,配置则 SSH 远程重启)
|
|
193
|
+
key: ~/.ssh/id_rsa
|
|
194
|
+
remote_dir: /opt/services/api
|
|
195
|
+
|
|
196
|
+
# ─────────────────────────────────────────
|
|
197
|
+
# 7. Kubernetes 部署
|
|
198
|
+
# ─────────────────────────────────────────
|
|
199
|
+
#
|
|
200
|
+
# 适用场景:K8s 集群
|
|
201
|
+
#
|
|
202
|
+
k8s_example:
|
|
203
|
+
type: k8s
|
|
204
|
+
target: staging # namespace(默认 default)
|
|
205
|
+
script: k8s/deployment.yaml # K8s manifest 文件路径(默认 k8s-deployment.yaml)
|
|
206
|
+
|
|
207
|
+
# ─────────────────────────────────────────
|
|
208
|
+
# 8. Helm 部署
|
|
209
|
+
# ─────────────────────────────────────────
|
|
210
|
+
#
|
|
211
|
+
# 适用场景:使用 Helm 管理 K8s 应用
|
|
212
|
+
#
|
|
213
|
+
helm_example:
|
|
214
|
+
type: helm
|
|
215
|
+
target: staging # namespace(默认环境名)
|
|
216
|
+
script: ./helm/h5 # Chart 路径(默认 ./helm/<端名>)
|
|
217
|
+
output_dir: values-staging.yaml # values 文件路径(默认 values-<env>.yaml)
|
|
218
|
+
|
|
219
|
+
# ─────────────────────────────────────────
|
|
220
|
+
# 9. Vercel 部署
|
|
221
|
+
# ─────────────────────────────────────────
|
|
222
|
+
#
|
|
223
|
+
# 适用场景:前端项目快速部署到 Vercel
|
|
224
|
+
#
|
|
225
|
+
vercel_example:
|
|
226
|
+
type: vercel
|
|
227
|
+
# 无需额外配置,执行 npx vercel --prod(production)或 npx vercel(preview)
|
|
228
|
+
# 需提前安装 Vercel CLI 并登录:npm i -g vercel && vercel login
|
|
229
|
+
|
|
230
|
+
# ─────────────────────────────────────────
|
|
231
|
+
# 10. Serverless 部署(函数计算)
|
|
232
|
+
# ─────────────────────────────────────────
|
|
233
|
+
#
|
|
234
|
+
# 适用场景:函数计算、无服务器架构
|
|
235
|
+
#
|
|
236
|
+
serverless_aliyun_example:
|
|
237
|
+
type: serverless
|
|
238
|
+
provider: aliyun-fc # 阿里云函数计算
|
|
239
|
+
target: my-func-name # 函数名(默认使用端名)
|
|
240
|
+
|
|
241
|
+
serverless_aws_example:
|
|
242
|
+
type: serverless
|
|
243
|
+
provider: aws-lambda # AWS Lambda
|
|
244
|
+
target: my-lambda-func
|
|
245
|
+
|
|
246
|
+
serverless_tencent_example:
|
|
247
|
+
type: serverless
|
|
248
|
+
provider: tencent-scf # 腾讯云云函数
|
|
249
|
+
target: my-scf-func
|
|
250
|
+
|
|
251
|
+
# ─────────────────────────────────────────
|
|
252
|
+
# 11. Java 后端部署(Spring Boot + systemd)
|
|
253
|
+
# ─────────────────────────────────────────
|
|
254
|
+
#
|
|
255
|
+
# 适用场景:Java 后端服务,通过 systemd 管理 jar 进程
|
|
256
|
+
#
|
|
257
|
+
# 服务器端准备(只需一次):
|
|
258
|
+
# 1) 将 templates/deploy-java/spring-boot.service 复制到服务器:
|
|
259
|
+
# /etc/systemd/system/order-service.service
|
|
260
|
+
# (文件名必须与 platform.name 一致)
|
|
261
|
+
# 2) 创建部署目录:mkdir -p /opt/services/order-service
|
|
262
|
+
# 3) 创建日志目录:mkdir -p /var/log/order-service
|
|
263
|
+
# 4) 重载 systemd:sudo systemctl daemon-reload
|
|
264
|
+
# 5) 启用开机自启:sudo systemctl enable order-service
|
|
265
|
+
#
|
|
266
|
+
# 数据库 / Redis 配置:
|
|
267
|
+
# 通过 Spring Boot profiles 切换,如 application-staging.yml
|
|
268
|
+
# 部署时激活 profile:script 中传入 --spring.profiles.active=staging
|
|
269
|
+
#
|
|
270
|
+
java_systemd_example:
|
|
271
|
+
type: ssh
|
|
272
|
+
build_cmd: mvn clean package -DskipTests -P staging
|
|
273
|
+
output_dir: target
|
|
274
|
+
host: deployer@staging-server.example.com:22
|
|
275
|
+
key: ~/.ssh/id_rsa
|
|
276
|
+
remote_dir: /opt/services/order-service
|
|
277
|
+
# 部署后执行:停止服务 → 替换 jar → 启动服务
|
|
278
|
+
script: sudo systemctl restart order-service
|
|
279
|
+
pre_deploy:
|
|
280
|
+
- echo "开始部署 Java 后端..."
|
|
281
|
+
post_deploy:
|
|
282
|
+
- echo "部署完成,检查状态..."
|
|
283
|
+
- ssh deployer@staging-server.example.com "sudo systemctl status order-service --no-pager"
|
|
284
|
+
|
|
285
|
+
# ─────────────────────────────────────────
|
|
286
|
+
# 12. Java 后端部署(Spring Boot + Docker)
|
|
287
|
+
# ─────────────────────────────────────────
|
|
288
|
+
#
|
|
289
|
+
# 适用场景:Java 服务容器化部署
|
|
290
|
+
#
|
|
291
|
+
# Dockerfile 示例见 templates/deploy-java/Dockerfile
|
|
292
|
+
#
|
|
293
|
+
java_docker_example:
|
|
294
|
+
type: docker
|
|
295
|
+
dockerfile: ./Dockerfile
|
|
296
|
+
registry: registry.example.com
|
|
297
|
+
image: my-project/order-service
|
|
298
|
+
tag: staging
|
|
299
|
+
|
|
300
|
+
# ═══════════════════════════════════════════════════════════
|
|
301
|
+
# 13. Nginx 站点配置(纯服务器托管前端,ssh 类型配套)
|
|
302
|
+
# ═══════════════════════════════════════════════════════════
|
|
303
|
+
#
|
|
304
|
+
# 适用场景:前端 ssh 类型部署到服务器后,由服务器 Nginx 托管。
|
|
305
|
+
# 服务器端完整站点配置模板见 templates/deploy-nginx/nginx-site.conf
|
|
306
|
+
# (含 SPA 回退、gzip、静态缓存、API 反代到本地后端、HTTPS/WebSocket)。
|
|
307
|
+
#
|
|
308
|
+
# 服务器端准备(只需一次):
|
|
309
|
+
# sudo cp templates/deploy-nginx/nginx-site.conf /etc/nginx/conf.d/<站点>.conf
|
|
310
|
+
# # 替换 {{DOMAIN}} / {{APP_DIR}} / {{BACKEND_HOST}} 后:
|
|
311
|
+
# sudo nginx -t && sudo nginx -s reload
|
|
312
|
+
#
|
|
313
|
+
nginx_site_example:
|
|
314
|
+
type: ssh
|
|
315
|
+
build_cmd: npm run build:staging
|
|
316
|
+
output_dir: dist
|
|
317
|
+
host: deployer@staging-server.example.com:22
|
|
318
|
+
key: ~/.ssh/id_rsa
|
|
319
|
+
remote_dir: /var/www/html/admin-web # 与站点配置的 {{APP_DIR}} 一致
|
|
320
|
+
script: sudo nginx -s reload # 部署完成后重载 Nginx
|
|
321
|
+
|
|
322
|
+
# ═══════════════════════════════════════════════════════════
|
|
323
|
+
# 14. Go 后端部署(systemd 管理,方式同 Java)
|
|
324
|
+
# ═══════════════════════════════════════════════════════════
|
|
325
|
+
#
|
|
326
|
+
# 适用场景:Go 服务编译为单个二进制,上传服务器由 systemd 管理。
|
|
327
|
+
# systemd service 模板参考 templates/deploy-java/spring-boot.service
|
|
328
|
+
# (将 ExecStart 改为二进制路径即可)。
|
|
329
|
+
#
|
|
330
|
+
go_systemd_example:
|
|
331
|
+
type: ssh
|
|
332
|
+
build_cmd: CGO_ENABLED=0 go build -o bin/gateway ./cmd/gateway
|
|
333
|
+
output_dir: bin
|
|
334
|
+
host: deployer@staging-server.example.com:22
|
|
335
|
+
key: ~/.ssh/id_rsa
|
|
336
|
+
remote_dir: /opt/services/gateway
|
|
337
|
+
script: sudo systemctl restart gateway
|
|
338
|
+
|
|
339
|
+
# Go 服务容器化部署
|
|
340
|
+
# Dockerfile 要点:多阶段(golang:1.22-alpine 编译 → alpine 运行),
|
|
341
|
+
# 运行阶段仅复制二进制,参考 deploy-java/Dockerfile 结构。
|
|
342
|
+
go_docker_example:
|
|
343
|
+
type: docker
|
|
344
|
+
dockerfile: ./Dockerfile
|
|
345
|
+
registry: registry.example.com
|
|
346
|
+
image: my-project/gateway
|
|
347
|
+
tag: staging
|
|
348
|
+
|
|
349
|
+
# ═══════════════════════════════════════════════════════════
|
|
350
|
+
# 15. Python 后端部署(gunicorn + systemd)
|
|
351
|
+
# ═══════════════════════════════════════════════════════════
|
|
352
|
+
#
|
|
353
|
+
# 适用场景:Django / Flask / FastAPI 服务,服务器上用 gunicorn 运行。
|
|
354
|
+
# 建议直接使用 ssh 类型 + 自定义脚本完成:构建(打包依赖)→ 上传 → 重启。
|
|
355
|
+
#
|
|
356
|
+
python_gunicorn_example:
|
|
357
|
+
type: script
|
|
358
|
+
build_cmd: pip install -r requirements.txt -t dist/
|
|
359
|
+
script: ./scripts/deploy-python.sh
|
|
360
|
+
# deploy-python.sh 内容示例(上传 + 重启 gunicorn):
|
|
361
|
+
# rsync -az --delete dist/ deployer@server:/opt/services/api/app/
|
|
362
|
+
# ssh deployer@server "sudo systemctl restart api-gunicorn"
|
|
363
|
+
|
|
364
|
+
# ═══════════════════════════════════════════════════════════
|
|
365
|
+
# 完整 PROJECT.yaml 示例(含部署配置)
|
|
366
|
+
# ═══════════════════════════════════════════════════════════
|
|
367
|
+
|
|
368
|
+
platforms:
|
|
369
|
+
- name: sr-web-operation
|
|
370
|
+
type: frontend
|
|
371
|
+
description: 运营管理前端
|
|
372
|
+
code_path: ./sr-web-operation
|
|
373
|
+
default_branch: main
|
|
374
|
+
requirement_unit: 运营管理
|
|
375
|
+
deploy:
|
|
376
|
+
staging:
|
|
377
|
+
type: ssh
|
|
378
|
+
build_cmd: npm run build:staging
|
|
379
|
+
output_dir: dist
|
|
380
|
+
host: deployer@staging-server.example.com
|
|
381
|
+
key: ~/.ssh/id_rsa
|
|
382
|
+
remote_dir: /var/www/html/sr-web-operation
|
|
383
|
+
script: sudo nginx -s reload
|
|
384
|
+
production:
|
|
385
|
+
type: ssh
|
|
386
|
+
build_cmd: npm run build:prod
|
|
387
|
+
output_dir: dist
|
|
388
|
+
host: deployer@prod-server.example.com
|
|
389
|
+
key: ~/.ssh/id_rsa_production
|
|
390
|
+
remote_dir: /var/www/html/sr-web-operation
|
|
391
|
+
script: sudo nginx -s reload
|
|
392
|
+
|
|
393
|
+
- name: api-service
|
|
394
|
+
type: backend
|
|
395
|
+
description: API 服务
|
|
396
|
+
code_path: ./api-service
|
|
397
|
+
default_branch: main
|
|
398
|
+
deploy:
|
|
399
|
+
staging:
|
|
400
|
+
type: pm2
|
|
401
|
+
build_cmd: npm run build
|
|
402
|
+
pm2_config: ecosystem.config.js
|
|
403
|
+
host: deployer@staging-server.example.com
|
|
404
|
+
key: ~/.ssh/id_rsa
|
|
405
|
+
remote_dir: /opt/services/api-service
|
|
406
|
+
|
|
407
|
+
# ═══════════════════════════════════════════════════════════
|
|
408
|
+
# 环境配置文件示例(.speccore/environments/staging.yaml)
|
|
409
|
+
# ═══════════════════════════════════════════════════════════
|
|
410
|
+
#
|
|
411
|
+
# 环境配置会与 PROJECT.yaml 的 deploy 段合并,优先级:环境配置 > PROJECT.yaml
|
|
412
|
+
#
|
|
413
|
+
|
|
414
|
+
branch: develop # pipeline 命令的目标分支
|
|
415
|
+
build_cmd: npm run build:staging # 覆盖 PROJECT.yaml 的构建命令
|
|
416
|
+
|
|
417
|
+
deploy:
|
|
418
|
+
type: ssh
|
|
419
|
+
host: deployer@staging-server.example.com:22
|
|
420
|
+
key: ~/.ssh/id_rsa
|
|
421
|
+
remote_dir: /var/www/html/sr-web-operation
|
|
422
|
+
|
|
423
|
+
# ═══════════════════════════════════════════════════════════
|
|
424
|
+
# 常用脚本示例(实体文件见 templates/deploy-scripts/)
|
|
425
|
+
# ═══════════════════════════════════════════════════════════
|
|
426
|
+
#
|
|
427
|
+
# 脚本实体与说明:
|
|
428
|
+
# templates/deploy-scripts/trigger-jenkins.sh Jenkins 构建触发
|
|
429
|
+
# templates/deploy-scripts/deploy-ftp.sh lftp FTP 上传
|
|
430
|
+
# templates/deploy-scripts/deploy-password-ssh.sh sshpass 密码 SSH
|
|
431
|
+
# templates/deploy-scripts/deploy-compose.sh docker-compose 编排
|
|
432
|
+
# templates/deploy-scripts/deploy-python.sh Python gunicorn 部署
|
|
433
|
+
# templates/deploy-java/deploy.sh 服务器端 Java 部署(备份→替换→重启)
|
|
434
|
+
# templates/deploy-docker/deploy-remote.sh 服务器端 Docker 容器管理
|
|
435
|
+
#
|
|
436
|
+
# 以下为脚本要点摘录(完整版以实体文件为准):
|
|
437
|
+
|
|
438
|
+
# --- trigger-jenkins.sh(要点)---
|
|
439
|
+
# #!/bin/bash
|
|
440
|
+
# curl -X POST \
|
|
441
|
+
# -u "$JENKINS_USER:$JENKINS_TOKEN" \
|
|
442
|
+
# "http://jenkins.example.com/job/my-project-$1/build"
|
|
443
|
+
|
|
444
|
+
# --- deploy-ftp.sh(要点,完整版含环境变量校验)---
|
|
445
|
+
# #!/bin/bash
|
|
446
|
+
# # 使用 lftp 进行 FTP 上传(支持密码)
|
|
447
|
+
# lftp -u "$FTP_USER,$FTP_PASS" "$FTP_HOST" <<EOF
|
|
448
|
+
# set ssl:verify-certificate no
|
|
449
|
+
# mirror -R dist /public_html/h5
|
|
450
|
+
# bye
|
|
451
|
+
# EOF
|
|
452
|
+
|
|
453
|
+
# --- deploy-password-ssh.sh(要点,完整版含环境变量校验)---
|
|
454
|
+
# #!/bin/bash
|
|
455
|
+
# # 使用 sshpass 进行密码认证的 SSH 部署(需安装 sshpass)
|
|
456
|
+
# # macOS: brew install sshpass
|
|
457
|
+
# # Ubuntu: apt-get install sshpass
|
|
458
|
+
# sshpass -p "$SSH_PASSWORD" scp -r dist/* "$SSH_USER@$SSH_HOST:$REMOTE_DIR/"
|
|
459
|
+
# sshpass -p "$SSH_PASSWORD" ssh "$SSH_USER@$SSH_HOST" "sudo nginx -s reload"
|
|
460
|
+
|
|
461
|
+
# --- deploy-java.sh(实体:templates/deploy-java/deploy.sh,服务器端执行)---
|
|
462
|
+
# #!/bin/bash
|
|
463
|
+
# # Java 后端部署脚本(放在服务器上,由 SSH 调用或手动执行)
|
|
464
|
+
# APP_NAME="${1:-order-service}"
|
|
465
|
+
# DEPLOY_DIR="/opt/services/$APP_NAME"
|
|
466
|
+
# BACKUP_DIR="/opt/services/$APP_NAME/backups"
|
|
467
|
+
# JAR_FILE="$DEPLOY_DIR/$APP_NAME.jar"
|
|
468
|
+
# NEW_JAR="$DEPLOY_DIR/$APP_NAME-new.jar"
|
|
469
|
+
#
|
|
470
|
+
# # 1. 备份旧版本
|
|
471
|
+
# mkdir -p "$BACKUP_DIR"
|
|
472
|
+
# if [ -f "$JAR_FILE" ]; then
|
|
473
|
+
# cp "$JAR_FILE" "$BACKUP_DIR/$APP_NAME-$(date +%Y%m%d-%H%M%S).jar"
|
|
474
|
+
# # 只保留最近 5 个备份
|
|
475
|
+
# ls -t "$BACKUP_DIR"/*.jar | tail -n +6 | xargs -r rm -f
|
|
476
|
+
# fi
|
|
477
|
+
#
|
|
478
|
+
# # 2. 替换 jar
|
|
479
|
+
# if [ -f "$NEW_JAR" ]; then
|
|
480
|
+
# mv "$NEW_JAR" "$JAR_FILE"
|
|
481
|
+
# else
|
|
482
|
+
# echo "错误:未找到新 jar 文件 $NEW_JAR"
|
|
483
|
+
# exit 1
|
|
484
|
+
# fi
|
|
485
|
+
#
|
|
486
|
+
# # 3. 重启服务
|
|
487
|
+
# sudo systemctl restart "$APP_NAME"
|
|
488
|
+
# sleep 2
|
|
489
|
+
# sudo systemctl status "$APP_NAME" --no-pager
|
|
490
|
+
|
|
491
|
+
# --- systemd service 文件示例(/etc/systemd/system/order-service.service) ---
|
|
492
|
+
# [Unit]
|
|
493
|
+
# Description=Order Service
|
|
494
|
+
# After=network.target
|
|
495
|
+
#
|
|
496
|
+
# [Service]
|
|
497
|
+
# Type=simple
|
|
498
|
+
# User=deployer
|
|
499
|
+
# Group=deployer
|
|
500
|
+
# WorkingDirectory=/opt/services/order-service
|
|
501
|
+
# Environment="SPRING_PROFILES_ACTIVE=staging"
|
|
502
|
+
# Environment="JAVA_OPTS=-Xms512m -Xmx1024m -Dfile.encoding=UTF-8"
|
|
503
|
+
# ExecStart=/usr/bin/java $JAVA_OPTS -jar order-service.jar
|
|
504
|
+
# ExecStop=/bin/kill -SIGTERM $MAINPID
|
|
505
|
+
# Restart=on-failure
|
|
506
|
+
# RestartSec=10
|
|
507
|
+
# StandardOutput=append:/var/log/order-service/app.log
|
|
508
|
+
# StandardError=append:/var/log/order-service/error.log
|
|
509
|
+
#
|
|
510
|
+
# [Install]
|
|
511
|
+
# WantedBy=multi-user.target
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# ═══════════════════════════════════════════════════════════
|
|
2
|
+
# Spring Boot Docker 构建示例
|
|
3
|
+
# ═══════════════════════════════════════════════════════════
|
|
4
|
+
#
|
|
5
|
+
# 用法:
|
|
6
|
+
# 1. 将本文件复制到 Java 工程根目录(与 pom.xml 同级)
|
|
7
|
+
# 2. 在 PROJECT.yaml 中配置 docker 类型部署:
|
|
8
|
+
# deploy:
|
|
9
|
+
# staging:
|
|
10
|
+
# type: docker
|
|
11
|
+
# dockerfile: ./Dockerfile
|
|
12
|
+
# registry: registry.example.com
|
|
13
|
+
# image: my-project/order-service
|
|
14
|
+
# tag: staging
|
|
15
|
+
# 3. 执行: speccore deploy --env staging --platform order-service
|
|
16
|
+
#
|
|
17
|
+
# 多阶段构建:先编译,再复制 jar 到精简镜像
|
|
18
|
+
# ═══════════════════════════════════════════════════════════
|
|
19
|
+
|
|
20
|
+
# ── 阶段 1:构建 ──
|
|
21
|
+
FROM maven:3.9-eclipse-temurin-17-alpine AS builder
|
|
22
|
+
WORKDIR /build
|
|
23
|
+
COPY pom.xml .
|
|
24
|
+
COPY src ./src
|
|
25
|
+
RUN mvn clean package -DskipTests -P docker
|
|
26
|
+
|
|
27
|
+
# ── 阶段 2:运行 ──
|
|
28
|
+
FROM eclipse-temurin:17-jre-alpine
|
|
29
|
+
WORKDIR /app
|
|
30
|
+
|
|
31
|
+
# 创建非 root 用户(安全最佳实践)
|
|
32
|
+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
33
|
+
|
|
34
|
+
# 复制构建产物
|
|
35
|
+
COPY --from=builder /build/target/*.jar app.jar
|
|
36
|
+
|
|
37
|
+
# 环境变量(可在运行时通过 -e 覆盖)
|
|
38
|
+
ENV SPRING_PROFILES_ACTIVE=staging
|
|
39
|
+
ENV JAVA_OPTS="-Xms512m -Xmx1024m -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/./urandom"
|
|
40
|
+
|
|
41
|
+
# 暴露端口(根据实际应用修改)
|
|
42
|
+
EXPOSE 8080
|
|
43
|
+
|
|
44
|
+
# 健康检查
|
|
45
|
+
HEALTHCHECK --interval=30s --timeout=3s --start-period=60s --retries=3 \
|
|
46
|
+
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/actuator/health || exit 1
|
|
47
|
+
|
|
48
|
+
USER appuser
|
|
49
|
+
|
|
50
|
+
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]
|