git-push-deploy-cli 0.3.1 β 0.6.1
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.md +466 -108
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +58 -18
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/daemon.d.ts +10 -0
- package/dist/commands/daemon.d.ts.map +1 -0
- package/dist/commands/daemon.js +67 -0
- package/dist/commands/daemon.js.map +1 -0
- package/dist/commands/deploy.d.ts +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +5 -2
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +36 -19
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +98 -3
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/logs.d.ts +1 -0
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +4 -1
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/release.d.ts +1 -1
- package/dist/commands/release.d.ts.map +1 -1
- package/dist/commands/release.js +162 -8
- package/dist/commands/release.js.map +1 -1
- package/dist/commands/stage.d.ts.map +1 -1
- package/dist/commands/stage.js +4 -3
- package/dist/commands/stage.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +15 -2
- package/dist/commands/status.js.map +1 -1
- package/dist/config/types.d.ts +112 -14
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +20 -0
- package/dist/config/types.js.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/git.d.ts +8 -0
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +22 -0
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/notifications.d.ts +6 -0
- package/dist/utils/notifications.d.ts.map +1 -0
- package/dist/utils/notifications.js +188 -0
- package/dist/utils/notifications.js.map +1 -0
- package/dist/utils/shell.d.ts +4 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +18 -0
- package/dist/utils/shell.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,24 +1,223 @@
|
|
|
1
1
|
# git-push-deploy-cli (gpd)
|
|
2
2
|
|
|
3
|
-
Git Push Deploy -
|
|
3
|
+
> **Git Push Deploy** - Deploy Node.js applications with a single `git push`. Zero-downtime, multi-server, with Slack/Discord notifications.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/git-push-deploy-cli)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
- **PM2 integration**: Automatic process restarts with user isolation
|
|
9
|
-
- **Lazy initialization**: Deploy repo created on first `gpd stage`
|
|
10
|
-
- **SSH orchestration**: Server setup from your dev machine
|
|
11
|
-
- **Config-driven**: Define services in `.git-deploy.json`
|
|
8
|
+
## π― What is GPD?
|
|
12
9
|
|
|
13
|
-
|
|
10
|
+
GPD is a deployment tool that uses Git's push mechanism to deploy your applications. Push your code, and the server automatically installs dependencies and restarts your app - with zero downtime.
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
14
|
+
β GPD DEPLOYMENT FLOW β
|
|
15
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
|
16
|
+
β β
|
|
17
|
+
β Developer Machine Production Server β
|
|
18
|
+
β βββββββββββββββββ βββββββββββββββββ β
|
|
19
|
+
β β
|
|
20
|
+
β βββββββββββββββ git push SSH βββββββββββββββββββ β
|
|
21
|
+
β β gpd deploy β ββββββββββββββββββββββββββΆβ Bare Git Repo β β
|
|
22
|
+
β βββββββββββββββ ββββββββββ¬βββββββββ β
|
|
23
|
+
β β β β
|
|
24
|
+
β β 1. Build β 2. post-receive β
|
|
25
|
+
β β 2. Stage artifacts β hook triggers β
|
|
26
|
+
β β 3. Commit βΌ β
|
|
27
|
+
β β 4. Push βββββββββββββββββββ β
|
|
28
|
+
β β β gpd install β β
|
|
29
|
+
β β β βββββββββββββ β β
|
|
30
|
+
β β β β’ git checkout β β
|
|
31
|
+
β β β β’ npm install β β
|
|
32
|
+
β β β β’ pm2 reload β β
|
|
33
|
+
β β ββββββββββ¬βββββββββ β
|
|
34
|
+
β β β β
|
|
35
|
+
β β 5. Send notification β 3. App restarted β
|
|
36
|
+
β β to Slack/Discord βΌ β
|
|
37
|
+
β β βββββββββββββββββββ β
|
|
38
|
+
β βΌ β App Running β β
|
|
39
|
+
β βββββββββββββββ β (zero-downtime)β β
|
|
40
|
+
β β π± Slack/ β βββββββββββββββββββ β
|
|
41
|
+
β β Discord β β
|
|
42
|
+
β βββββββββββββββ β
|
|
43
|
+
β β β
|
|
44
|
+
β βββ Developer receives: "β
my-api deployed successfully" β
|
|
45
|
+
β β
|
|
46
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## ποΈ Architecture Overview
|
|
50
|
+
|
|
51
|
+
### GPD: One Tool, Two Roles (Janus Architecture)
|
|
52
|
+
|
|
53
|
+
GPD is installed **both locally and on the server**. The same CLI serves different purposes depending on where it runs:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
57
|
+
β GPD JANUS ARCHITECTURE β
|
|
58
|
+
β (Same CLI, Two Roles) β
|
|
59
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
|
60
|
+
β β
|
|
61
|
+
β βββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββ β
|
|
62
|
+
β β LOCAL (Dev Machine) β β SERVER (Production) β β
|
|
63
|
+
β β ββββββββββββββββββββ β β ββββββββββββββββββββ β β
|
|
64
|
+
β β β β β β
|
|
65
|
+
β β $ gpd deploy β β $ gpd install β β
|
|
66
|
+
β β $ gpd init β β (called by git hook) β β
|
|
67
|
+
β β $ gpd stage β β β β
|
|
68
|
+
β β $ gpd release β β β β
|
|
69
|
+
β β $ gpd rollback β β β β
|
|
70
|
+
β β $ gpd config β β β β
|
|
71
|
+
β β $ gpd logs (via SSH) β β β β
|
|
72
|
+
β β $ gpd daemon (via SSH) β β β β
|
|
73
|
+
β β β β β β
|
|
74
|
+
β βββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββ β
|
|
75
|
+
β β β² β
|
|
76
|
+
β β β β
|
|
77
|
+
β β 1. git push β 2. post-receive β
|
|
78
|
+
β β (artifacts) β hook calls β
|
|
79
|
+
β β β gpd install β
|
|
80
|
+
β βΌ β β
|
|
81
|
+
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
|
|
82
|
+
β β β β
|
|
83
|
+
β β #!/bin/bash β β
|
|
84
|
+
β β # post-receive hook (generated by gpd init) β β
|
|
85
|
+
β β β β
|
|
86
|
+
β β gpd install my-service -c /opt/app/.git-deploy.json β β
|
|
87
|
+
β β β² β β
|
|
88
|
+
β β β β β
|
|
89
|
+
β β βββ GPD calls ITSELF on the server! β β
|
|
90
|
+
β β β β
|
|
91
|
+
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
|
|
92
|
+
β β
|
|
93
|
+
β Installation: β
|
|
94
|
+
β βββββββββββββ β
|
|
95
|
+
β β
|
|
96
|
+
β # On dev machine # On server β
|
|
97
|
+
β npm install -g git-push-deploy-cli npm install -g git-push-deploy-cli β
|
|
98
|
+
β β
|
|
99
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Deployment Architecture
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
106
|
+
β WORKSPACE STRUCTURE β
|
|
107
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
|
108
|
+
β β
|
|
109
|
+
β Your Workspace (local) β
|
|
110
|
+
β ββββββββββββββββββββββ β
|
|
111
|
+
β workspace/ β
|
|
112
|
+
β βββ .git-deploy.json βββ GPD configuration β
|
|
113
|
+
β β β
|
|
114
|
+
β βββ my-api/ (your project) β
|
|
115
|
+
β βββ src/ source code β
|
|
116
|
+
β βββ dist/ build output β
|
|
117
|
+
β βββ package.json β
|
|
118
|
+
β β β
|
|
119
|
+
β βββ deploy/ βββ GPD creates this β
|
|
120
|
+
β βββ staging/ deploy repo for staging β
|
|
121
|
+
β β βββ .git βββββββββββββββββββββ β
|
|
122
|
+
β β βββ dist/ β points to β
|
|
123
|
+
β β βββ package.json β bare repo β
|
|
124
|
+
β β β β
|
|
125
|
+
β βββ production/ β β
|
|
126
|
+
β βββ .git βββββββββββββββββββββΌββββ β
|
|
127
|
+
β βββ dist/ β β β
|
|
128
|
+
β βββ package.json β β β
|
|
129
|
+
β β β β
|
|
130
|
+
ββββββββββββββββββββββββββββββββββββββββββββββΌββββΌβββββββββββββββββββββββββββββ€
|
|
131
|
+
β β β β
|
|
132
|
+
β Server (remote via SSH) β β β
|
|
133
|
+
β βββββββββββββββββββββββ β β β
|
|
134
|
+
β βΌ βΌ β
|
|
135
|
+
β /git/deploy/ Bare Git Repositories β
|
|
136
|
+
β βββ staging/my-api/ (receive pushes) β
|
|
137
|
+
β β βββ hooks/post-receive triggers gpd install β
|
|
138
|
+
β β β
|
|
139
|
+
β βββ production/my-api/ β
|
|
140
|
+
β βββ hooks/post-receive β
|
|
141
|
+
β β
|
|
142
|
+
β /opt/apps/ Application Directories β
|
|
143
|
+
β βββ staging/my-api/ (where code runs) β
|
|
144
|
+
β β βββ dist/ β
|
|
145
|
+
β β βββ package.json β
|
|
146
|
+
β β βββ node_modules/ β
|
|
147
|
+
β β βββ .env βββ generated from config β
|
|
148
|
+
β β β
|
|
149
|
+
β βββ production/my-api/ β
|
|
150
|
+
β βββ dist/ β
|
|
151
|
+
β βββ ... β
|
|
152
|
+
β β
|
|
153
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Runtime Architecture
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
160
|
+
β RUNTIME / HOSTING β
|
|
161
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
|
162
|
+
β β
|
|
163
|
+
β Server β
|
|
164
|
+
β ββββββ β
|
|
165
|
+
β β
|
|
166
|
+
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
|
|
167
|
+
β β Process Manager (PM2 or GPDD) β β
|
|
168
|
+
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β
|
|
169
|
+
β β β β
|
|
170
|
+
β β PM2 Mode GPDD Mode (Zero-Downtime) β β
|
|
171
|
+
β β ββββββββ βββββββββββββββββββββββββ β β
|
|
172
|
+
β β β β
|
|
173
|
+
β β βββββββββββ βββββββββββββββββββββββ β β
|
|
174
|
+
β β β PM2 β β GPDD Master β β β
|
|
175
|
+
β β β Daemon β β (cluster manager) β β β
|
|
176
|
+
β β ββββββ¬βββββ ββββββββββββ¬βββββββββββ β β
|
|
177
|
+
β β β β β β
|
|
178
|
+
β β β manages β manages β β
|
|
179
|
+
β β βΌ βΌ β β
|
|
180
|
+
β β βββββββββββ βββββββββββββββββββββββ β β
|
|
181
|
+
β β β App β β Worker 1 Worker 2 β β β
|
|
182
|
+
β β β Process β β Worker 3 Worker 4 β β β
|
|
183
|
+
β β βββββββββββ βββββββββββββββββββββββ β β
|
|
184
|
+
β β β β
|
|
185
|
+
β β restart on crash β’ Rolling restart β β
|
|
186
|
+
β β cluster mode β’ Zero-downtime reload β β
|
|
187
|
+
β β log management β’ Built-in clustering β β
|
|
188
|
+
β β β β
|
|
189
|
+
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
|
|
190
|
+
β β
|
|
191
|
+
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β
|
|
192
|
+
β β Port 3000 β β Port 3001 β β Port 3002 β β
|
|
193
|
+
β β my-api-staging β β my-api-prod β β other-service β β
|
|
194
|
+
β ββββββββββ¬βββββββββ ββββββββββ¬βββββββββ ββββββββββ¬βββββββββ β
|
|
195
|
+
β β β β β
|
|
196
|
+
β ββββββββββββββββββββββββΌβββββββββββββββββββββββ β
|
|
197
|
+
β β β
|
|
198
|
+
β βΌ β
|
|
199
|
+
β βββββββββββββββββββ β
|
|
200
|
+
β β Reverse Proxy β β
|
|
201
|
+
β β (nginx/caddy) β β
|
|
202
|
+
β ββββββββββ¬βββββββββ β
|
|
203
|
+
β β β
|
|
204
|
+
β βΌ β
|
|
205
|
+
β Internet β
|
|
206
|
+
β β
|
|
207
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## β‘ Quick Start
|
|
211
|
+
|
|
212
|
+
### Installation
|
|
14
213
|
|
|
15
214
|
```bash
|
|
16
215
|
npm install -g git-push-deploy-cli
|
|
17
216
|
```
|
|
18
217
|
|
|
19
|
-
|
|
218
|
+
### 1. Configure your service
|
|
20
219
|
|
|
21
|
-
|
|
220
|
+
Create `.git-deploy.json` in your workspace root:
|
|
22
221
|
|
|
23
222
|
```json
|
|
24
223
|
{
|
|
@@ -26,141 +225,300 @@ npm install -g git-push-deploy-cli
|
|
|
26
225
|
"my-api-staging": {
|
|
27
226
|
"sourceDir": "my-api",
|
|
28
227
|
"deployRepo": "deploy/staging",
|
|
29
|
-
"artifacts": ["dist
|
|
228
|
+
"artifacts": ["dist", "package.json"],
|
|
30
229
|
"processManager": "pm2",
|
|
31
230
|
"processName": "my-api-staging",
|
|
32
|
-
"pm2Home": "/opt/myapp/.pm2",
|
|
33
|
-
"pm2User": "myapp",
|
|
34
231
|
"environment": "staging",
|
|
35
|
-
"env": {
|
|
36
|
-
"PORT": 5000,
|
|
37
|
-
"NODE_ENV": "staging"
|
|
38
|
-
},
|
|
39
232
|
"server": {
|
|
40
|
-
"host": "
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"bareRepo": "/git/deploy-myapp/staging/my-api",
|
|
44
|
-
"group": "deploy-myapp"
|
|
233
|
+
"host": "deploy@myserver.com",
|
|
234
|
+
"targetDir": "/opt/apps/staging/my-api",
|
|
235
|
+
"bareRepo": "/git/deploy/staging/my-api"
|
|
45
236
|
}
|
|
46
237
|
}
|
|
47
238
|
}
|
|
48
239
|
}
|
|
49
240
|
```
|
|
50
241
|
|
|
51
|
-
### 2. Initialize server (once
|
|
242
|
+
### 2. Initialize server (once)
|
|
52
243
|
|
|
53
244
|
```bash
|
|
54
245
|
gpd init my-api-staging
|
|
55
246
|
```
|
|
56
247
|
|
|
57
|
-
This creates via SSH:
|
|
58
|
-
- Bare git repository at `/git/deploy-myapp/staging/my-api`
|
|
59
|
-
- Target directory at `/opt/myapp/staging/my-api`
|
|
60
|
-
- Post-receive hook that calls `gpd install`
|
|
61
|
-
|
|
62
248
|
### 3. Deploy
|
|
63
249
|
|
|
64
250
|
```bash
|
|
65
251
|
gpd deploy my-api-staging
|
|
66
252
|
```
|
|
67
253
|
|
|
68
|
-
|
|
69
|
-
1. Creates deploy repo (if needed) at `my-api/deploy/staging/`
|
|
70
|
-
2. Copies build artifacts to deploy repo
|
|
71
|
-
3. Commits and pushes to bare repo on server
|
|
72
|
-
4. Server hook: `git checkout && npm install && pm2 restart`
|
|
254
|
+
That's it! Your app is now running on the server.
|
|
73
255
|
|
|
74
|
-
## Commands
|
|
256
|
+
## π Commands
|
|
75
257
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
258
|
+
```
|
|
259
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
260
|
+
β GPD COMMANDS β
|
|
261
|
+
ββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
|
262
|
+
β Command β Description β
|
|
263
|
+
ββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
|
264
|
+
β gpd status β Show all configured services β
|
|
265
|
+
β gpd config β Interactive configuration wizard β
|
|
266
|
+
β gpd init β Initialize server (bare repo, target dir, hooks) β
|
|
267
|
+
β gpd deploy β Full deployment (stage + release) β
|
|
268
|
+
β gpd stage β Copy build artifacts to deploy repo β
|
|
269
|
+
β gpd release β Commit and push to server β
|
|
270
|
+
β gpd rollback β Rollback to previous version β
|
|
271
|
+
β gpd logs β Show application logs from server β
|
|
272
|
+
β gpd daemon β Manage GPDD process (start/stop/status/logs) β
|
|
273
|
+
ββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
|
274
|
+
β Options β β
|
|
275
|
+
ββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
|
276
|
+
β -m, --message β Custom commit message β
|
|
277
|
+
β -n, --lines β Number of log lines (default: 50) β
|
|
278
|
+
β -f, --follow β Follow logs in real-time β
|
|
279
|
+
β --dry-run β Preview changes without executing β
|
|
280
|
+
ββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
281
|
+
```
|
|
85
282
|
|
|
86
|
-
##
|
|
283
|
+
## π§ Features
|
|
87
284
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
285
|
+
### Multi-Server Deployment
|
|
286
|
+
|
|
287
|
+
Deploy to multiple servers simultaneously:
|
|
288
|
+
|
|
289
|
+
```json
|
|
290
|
+
{
|
|
291
|
+
"services": {
|
|
292
|
+
"my-api-prod": {
|
|
293
|
+
"servers": [
|
|
294
|
+
{ "name": "primary", "host": "prod1.example.com", "targetDir": "/opt/app" },
|
|
295
|
+
{ "name": "replica", "host": "prod2.example.com", "targetDir": "/opt/app" }
|
|
296
|
+
]
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
93
300
|
```
|
|
94
301
|
|
|
95
|
-
|
|
302
|
+
```
|
|
303
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
304
|
+
β MULTI-SERVER DEPLOYMENT β
|
|
305
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
|
306
|
+
β β
|
|
307
|
+
β gpd deploy my-api-prod β
|
|
308
|
+
β β β
|
|
309
|
+
β β β
|
|
310
|
+
β ββββββββββββββββββΌβββββββββββββββββ β
|
|
311
|
+
β β β β β
|
|
312
|
+
β βΌ βΌ βΌ β
|
|
313
|
+
β ββββββββββββ ββββββββββββ ββββββββββββ β
|
|
314
|
+
β β Server 1 β β Server 2 β β Server 3 β β
|
|
315
|
+
β β (primary)β β (replica)β β (replica)β β
|
|
316
|
+
β ββββββββββββ ββββββββββββ ββββββββββββ β
|
|
317
|
+
β β β β β
|
|
318
|
+
β ββββββββββββββββββΌβββββββββββββββββ β
|
|
319
|
+
β β β
|
|
320
|
+
β βΌ β
|
|
321
|
+
β ββββββββββββββββββ β
|
|
322
|
+
β β Load Balancer β β
|
|
323
|
+
β ββββββββββββββββββ β
|
|
324
|
+
β β
|
|
325
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Deployment Hooks
|
|
329
|
+
|
|
330
|
+
Run custom scripts before/after deployment:
|
|
331
|
+
|
|
332
|
+
```json
|
|
333
|
+
{
|
|
334
|
+
"hooks": {
|
|
335
|
+
"preDeploy": ["npm run lint", "npm test"],
|
|
336
|
+
"postDeploy": ["npx prisma migrate deploy"],
|
|
337
|
+
"postDeployLocal": ["echo 'Deployed!'"]
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
```
|
|
343
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
344
|
+
β DEPLOYMENT HOOKS β
|
|
345
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
|
346
|
+
β β
|
|
347
|
+
β LOCAL (Developer Machine) SERVER β
|
|
348
|
+
β βββββββββββββββββββββββββ ββββββ β
|
|
349
|
+
β β
|
|
350
|
+
β βββββββββββββββββββββββ β
|
|
351
|
+
β β 1. preDeploy hooks β βββ npm run lint, npm test β
|
|
352
|
+
β β (local) β β
|
|
353
|
+
β ββββββββββββ¬βββββββββββ β
|
|
354
|
+
β β β
|
|
355
|
+
β βΌ β
|
|
356
|
+
β βββββββββββββββββββββββ βββββββββββββββββββββββ β
|
|
357
|
+
β β 2. git push β βββββββββββββββΆβ 3. post-receive β β
|
|
358
|
+
β βββββββββββββββββββββββ β hook β β
|
|
359
|
+
β ββββββββββββ¬βββββββββββ β
|
|
360
|
+
β β β
|
|
361
|
+
β βΌ β
|
|
362
|
+
β βββββββββββββββββββββββ β
|
|
363
|
+
β β 4. gpd install β β
|
|
364
|
+
β β β’ git checkout β β
|
|
365
|
+
β β β’ npm install β β
|
|
366
|
+
β ββββββββββββ¬βββββββββββ β
|
|
367
|
+
β β β
|
|
368
|
+
β βΌ β
|
|
369
|
+
β βββββββββββββββββββββββ β
|
|
370
|
+
β β 5. postDeploy hooks β β
|
|
371
|
+
β β (server) β β
|
|
372
|
+
β β e.g. prisma β β
|
|
373
|
+
β ββββββββββββ¬βββββββββββ β
|
|
374
|
+
β β β
|
|
375
|
+
β βΌ β
|
|
376
|
+
β βββββββββββββββββββββββ β
|
|
377
|
+
β β 6. Process restart β β
|
|
378
|
+
β βββββββββββββββββββββββ β (PM2/GPDD) β β
|
|
379
|
+
β β 7. postDeployLocal ββββββββββββββββββββββββββββββββββββββββ β
|
|
380
|
+
β β hooks β notification β
|
|
381
|
+
β βββββββββββββββββββββββ β
|
|
382
|
+
β β
|
|
383
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Notifications (Slack, Discord, Webhook)
|
|
387
|
+
|
|
388
|
+
Get notified on every deployment:
|
|
389
|
+
|
|
390
|
+
```json
|
|
391
|
+
{
|
|
392
|
+
"notifications": {
|
|
393
|
+
"slack": {
|
|
394
|
+
"webhookUrl": "https://hooks.slack.com/services/xxx",
|
|
395
|
+
"channel": "#deployments"
|
|
396
|
+
},
|
|
397
|
+
"discord": {
|
|
398
|
+
"webhookUrl": "https://discord.com/api/webhooks/xxx"
|
|
399
|
+
},
|
|
400
|
+
"webhook": {
|
|
401
|
+
"url": "https://your-api.com/deploy-hook",
|
|
402
|
+
"headers": { "Authorization": "Bearer xxx" }
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### Process Managers
|
|
409
|
+
|
|
410
|
+
GPD supports multiple process managers:
|
|
411
|
+
|
|
412
|
+
| Manager | Description | Use Case |
|
|
413
|
+
|---------|-------------|----------|
|
|
414
|
+
| `pm2` | Industry standard, feature-rich | Production, logging, monitoring |
|
|
415
|
+
| `gpdd` | Built-in, zero-downtime | Simple apps, zero-config |
|
|
416
|
+
| `systemd` | Linux system service | Server integration |
|
|
417
|
+
|
|
418
|
+
### Zero-Downtime with GPDD
|
|
419
|
+
|
|
420
|
+
```
|
|
421
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
422
|
+
β GPDD ZERO-DOWNTIME RELOAD β
|
|
423
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
|
424
|
+
β β
|
|
425
|
+
β Before Reload After gpdd reload β
|
|
426
|
+
β βββββββββββββ βββββββββββββββββ β
|
|
427
|
+
β β
|
|
428
|
+
β ββββββββββββββββ ββββββββββββββββ β
|
|
429
|
+
β β Master β β Master β β
|
|
430
|
+
β ββββββββ¬ββββββββ ββββββββ¬ββββββββ β
|
|
431
|
+
β β β β
|
|
432
|
+
β βββββββ΄ββββββ ββββββββ΄βββββββ β
|
|
433
|
+
β β β β β β
|
|
434
|
+
β βΌ βΌ βΌ βΌ β
|
|
435
|
+
β ββββββββ ββββββββ ββββββββ ββββββββ β
|
|
436
|
+
β β W1 β β W2 β β W1 β β W2 β β
|
|
437
|
+
β β OLD β β OLD β β NEW β β NEW β β
|
|
438
|
+
β ββββββββ ββββββββ ββββββββ ββββββββ β
|
|
439
|
+
β β
|
|
440
|
+
β Rolling restart: β
|
|
441
|
+
β 1. Start new W1 β
|
|
442
|
+
β 2. Stop old W1 (after ready) β
|
|
443
|
+
β 3. Start new W2 β
|
|
444
|
+
β 4. Stop old W2 β
|
|
445
|
+
β β
|
|
446
|
+
β β No dropped connections β
|
|
447
|
+
β β
|
|
448
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
## π Full Configuration Reference
|
|
96
452
|
|
|
97
453
|
```typescript
|
|
98
454
|
interface ServiceConfig {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
455
|
+
// Source & Deploy
|
|
456
|
+
sourceDir: string; // Project directory (e.g., "my-api")
|
|
457
|
+
deployRepo: string; // Deploy repo path (e.g., "deploy/staging")
|
|
458
|
+
artifacts: string[]; // Files to deploy (e.g., ["dist", "package.json"])
|
|
459
|
+
|
|
460
|
+
// Process Manager
|
|
461
|
+
processManager?: 'pm2' | 'gpdd' | 'systemd';
|
|
462
|
+
processName: string; // Process name
|
|
463
|
+
pm2Home?: string; // PM2_HOME directory
|
|
464
|
+
pm2User?: string; // User for PM2 (sudo -u)
|
|
465
|
+
gpddWorkers?: number; // GPDD worker count (0 = auto)
|
|
466
|
+
gpddEntryPoint?: string; // Entry point (default: dist/index.js)
|
|
467
|
+
|
|
468
|
+
// Environment
|
|
469
|
+
environment?: 'production' | 'staging' | 'development';
|
|
470
|
+
env?: Record<string, string | number | boolean>;
|
|
471
|
+
|
|
472
|
+
// Server (single)
|
|
473
|
+
server?: {
|
|
474
|
+
host: string; // SSH host (user@hostname)
|
|
475
|
+
sshOptions?: string; // SSH options (e.g., "-p 22")
|
|
476
|
+
targetDir: string; // Where code runs
|
|
477
|
+
bareRepo: string; // Git bare repo path
|
|
478
|
+
group?: string; // Unix group
|
|
479
|
+
name?: string; // Display name
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
// Servers (multi)
|
|
483
|
+
servers?: ServerConfig[]; // Multiple servers
|
|
484
|
+
|
|
485
|
+
// Hooks
|
|
486
|
+
hooks?: {
|
|
487
|
+
preDeploy?: string[]; // Run locally before push
|
|
488
|
+
postDeploy?: string[]; // Run on server after install
|
|
489
|
+
postDeployLocal?: string[]; // Run locally after success
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
// Notifications
|
|
493
|
+
notifications?: {
|
|
494
|
+
slack?: { webhookUrl: string; channel?: string; };
|
|
495
|
+
discord?: { webhookUrl: string; };
|
|
496
|
+
webhook?: { url: string; headers?: Record<string, string>; };
|
|
114
497
|
};
|
|
115
498
|
}
|
|
116
499
|
```
|
|
117
500
|
|
|
118
|
-
##
|
|
501
|
+
## π οΈ Server Prerequisites
|
|
119
502
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
βββ .env (generated)
|
|
503
|
+
- **Node.js** (18+ recommended)
|
|
504
|
+
- **Git**
|
|
505
|
+
- **SSH access** from dev machine
|
|
506
|
+
- **PM2** or **GPDD** (installed globally)
|
|
507
|
+
- **GPD CLI** (installed globally on server)
|
|
508
|
+
|
|
509
|
+
```bash
|
|
510
|
+
# On server
|
|
511
|
+
npm install -g pm2 git-push-deploy-cli
|
|
512
|
+
# Or for GPDD
|
|
513
|
+
npm install -g git-push-deploy-daemon git-push-deploy-cli
|
|
132
514
|
```
|
|
133
515
|
|
|
134
|
-
##
|
|
516
|
+
## π More Documentation
|
|
135
517
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
ββ gpd stage
|
|
142
|
-
β ββ Copy artifacts β my-api/deploy/staging/
|
|
143
|
-
β
|
|
144
|
-
ββ gpd release
|
|
145
|
-
ββ git push ββββββββββββββββ /git/deploy-myapp/staging/my-api
|
|
146
|
-
β
|
|
147
|
-
ββ post-receive hook:
|
|
148
|
-
gpd install my-api-staging
|
|
149
|
-
β
|
|
150
|
-
ββ git checkout -f
|
|
151
|
-
ββ .env generation
|
|
152
|
-
ββ npm install --omit=dev
|
|
153
|
-
ββ pm2 restart
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
## Server Prerequisites
|
|
157
|
-
|
|
158
|
-
- Node.js + npm
|
|
159
|
-
- PM2 (`npm install -g pm2`)
|
|
160
|
-
- gpd CLI (`npm install -g git-push-deploy-cli`)
|
|
161
|
-
- SSH access from dev machine
|
|
162
|
-
- Git
|
|
163
|
-
|
|
164
|
-
## License
|
|
518
|
+
- [Git-Based Deployment Guide](../docs/git-based-deployment.md)
|
|
519
|
+
- [PM2 Process Management](../docs/pm2-process-management.md)
|
|
520
|
+
- [GPDD Daemon Documentation](../git-push-deploy-daemon/README.md)
|
|
521
|
+
|
|
522
|
+
## π License
|
|
165
523
|
|
|
166
524
|
MIT
|