suthep 0.1.0 → 0.2.0-beta.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 +172 -71
- package/dist/commands/deploy.js +251 -37
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/down.js +179 -0
- package/dist/commands/down.js.map +1 -0
- package/dist/commands/redeploy.js +59 -0
- package/dist/commands/redeploy.js.map +1 -0
- package/dist/commands/up.js +213 -0
- package/dist/commands/up.js.map +1 -0
- package/dist/index.js +36 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/certbot.js +40 -3
- package/dist/utils/certbot.js.map +1 -1
- package/dist/utils/config-loader.js +30 -0
- package/dist/utils/config-loader.js.map +1 -1
- package/dist/utils/deployment.js +49 -16
- package/dist/utils/deployment.js.map +1 -1
- package/dist/utils/docker.js +396 -25
- package/dist/utils/docker.js.map +1 -1
- package/dist/utils/nginx.js +167 -8
- package/dist/utils/nginx.js.map +1 -1
- package/docs/README.md +25 -49
- package/docs/english/01-introduction.md +84 -0
- package/docs/english/02-installation.md +200 -0
- package/docs/english/03-quick-start.md +256 -0
- package/docs/english/04-configuration.md +358 -0
- package/docs/english/05-commands.md +363 -0
- package/docs/english/06-examples.md +456 -0
- package/docs/english/07-troubleshooting.md +417 -0
- package/docs/english/08-advanced.md +411 -0
- package/docs/english/README.md +48 -0
- package/docs/thai/01-introduction.md +84 -0
- package/docs/thai/02-installation.md +200 -0
- package/docs/thai/03-quick-start.md +256 -0
- package/docs/thai/04-configuration.md +358 -0
- package/docs/thai/05-commands.md +363 -0
- package/docs/thai/06-examples.md +456 -0
- package/docs/thai/07-troubleshooting.md +417 -0
- package/docs/thai/08-advanced.md +411 -0
- package/docs/thai/README.md +48 -0
- package/example/README.md +286 -53
- package/example/suthep-complete.yml +103 -0
- package/example/suthep-docker-only.yml +71 -0
- package/example/suthep-no-docker.yml +51 -0
- package/example/suthep-path-routing.yml +62 -0
- package/example/suthep.example.yml +89 -0
- package/package.json +1 -1
- package/src/commands/deploy.ts +322 -50
- package/src/commands/down.ts +240 -0
- package/src/commands/redeploy.ts +78 -0
- package/src/commands/up.ts +271 -0
- package/src/index.ts +62 -1
- package/src/types/config.ts +25 -24
- package/src/utils/certbot.ts +68 -6
- package/src/utils/config-loader.ts +40 -0
- package/src/utils/deployment.ts +61 -36
- package/src/utils/docker.ts +634 -30
- package/src/utils/nginx.ts +187 -4
- package/suthep-0.1.0-beta.1.tgz +0 -0
- package/suthep-0.1.1.tgz +0 -0
- package/suthep.example.yml +34 -0
- package/suthep.yml +39 -0
- package/test +0 -0
- package/docs/api-reference.md +0 -545
- package/docs/architecture.md +0 -367
- package/docs/commands.md +0 -273
- package/docs/configuration.md +0 -347
- package/docs/examples.md +0 -537
- package/docs/getting-started.md +0 -197
- package/docs/troubleshooting.md +0 -441
- package/example/docker-compose.yml +0 -72
- package/example/suthep.yml +0 -31
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
# Examples
|
|
2
|
+
|
|
3
|
+
This guide provides real-world examples of deploying different types of services with Suthep.
|
|
4
|
+
|
|
5
|
+
## Example 1: Simple Node.js API
|
|
6
|
+
|
|
7
|
+
Deploy a Node.js API service with health checks.
|
|
8
|
+
|
|
9
|
+
### Configuration
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
project:
|
|
13
|
+
name: my-api
|
|
14
|
+
version: 1.0.0
|
|
15
|
+
|
|
16
|
+
services:
|
|
17
|
+
- name: api
|
|
18
|
+
port: 3000
|
|
19
|
+
domains:
|
|
20
|
+
- api.example.com
|
|
21
|
+
healthCheck:
|
|
22
|
+
path: /health
|
|
23
|
+
interval: 30
|
|
24
|
+
environment:
|
|
25
|
+
NODE_ENV: production
|
|
26
|
+
PORT: 3000
|
|
27
|
+
|
|
28
|
+
nginx:
|
|
29
|
+
configPath: /etc/nginx/sites-available
|
|
30
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
31
|
+
|
|
32
|
+
certbot:
|
|
33
|
+
email: admin@example.com
|
|
34
|
+
staging: false
|
|
35
|
+
|
|
36
|
+
deployment:
|
|
37
|
+
strategy: rolling
|
|
38
|
+
healthCheckTimeout: 30000
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Deployment
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
suthep setup
|
|
45
|
+
suthep deploy
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Result
|
|
49
|
+
|
|
50
|
+
- Service available at `https://api.example.com`
|
|
51
|
+
- Health checks performed every 30 seconds
|
|
52
|
+
- Automatic SSL certificate from Let's Encrypt
|
|
53
|
+
|
|
54
|
+
## Example 2: Docker Web Application
|
|
55
|
+
|
|
56
|
+
Deploy a web application using a Docker container.
|
|
57
|
+
|
|
58
|
+
### Configuration
|
|
59
|
+
|
|
60
|
+
```yaml
|
|
61
|
+
project:
|
|
62
|
+
name: webapp
|
|
63
|
+
version: 1.0.0
|
|
64
|
+
|
|
65
|
+
services:
|
|
66
|
+
- name: webapp
|
|
67
|
+
port: 8080
|
|
68
|
+
docker:
|
|
69
|
+
image: nginx:latest
|
|
70
|
+
container: webapp-container
|
|
71
|
+
port: 80
|
|
72
|
+
domains:
|
|
73
|
+
- example.com
|
|
74
|
+
- www.example.com
|
|
75
|
+
healthCheck:
|
|
76
|
+
path: /
|
|
77
|
+
interval: 30
|
|
78
|
+
|
|
79
|
+
nginx:
|
|
80
|
+
configPath: /etc/nginx/sites-available
|
|
81
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
82
|
+
|
|
83
|
+
certbot:
|
|
84
|
+
email: admin@example.com
|
|
85
|
+
staging: false
|
|
86
|
+
|
|
87
|
+
deployment:
|
|
88
|
+
strategy: rolling
|
|
89
|
+
healthCheckTimeout: 30000
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Deployment
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
suthep deploy
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Result
|
|
99
|
+
|
|
100
|
+
- Docker container running on port 8080
|
|
101
|
+
- Service available at `https://example.com` and `https://www.example.com`
|
|
102
|
+
- Automatic container management
|
|
103
|
+
|
|
104
|
+
## Example 3: Multiple Services on Same Domain
|
|
105
|
+
|
|
106
|
+
Route multiple services on the same domain using path-based routing.
|
|
107
|
+
|
|
108
|
+
### Configuration
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
project:
|
|
112
|
+
name: fullstack-app
|
|
113
|
+
version: 1.0.0
|
|
114
|
+
|
|
115
|
+
services:
|
|
116
|
+
# API service on /api path
|
|
117
|
+
- name: api
|
|
118
|
+
port: 3001
|
|
119
|
+
path: /api
|
|
120
|
+
domains:
|
|
121
|
+
- example.com
|
|
122
|
+
docker:
|
|
123
|
+
image: myapp/api:latest
|
|
124
|
+
container: api-container
|
|
125
|
+
port: 3001
|
|
126
|
+
healthCheck:
|
|
127
|
+
path: /api/health
|
|
128
|
+
interval: 30
|
|
129
|
+
|
|
130
|
+
# UI service on root path
|
|
131
|
+
- name: ui
|
|
132
|
+
port: 3000
|
|
133
|
+
path: /
|
|
134
|
+
domains:
|
|
135
|
+
- example.com
|
|
136
|
+
docker:
|
|
137
|
+
image: myapp/ui:latest
|
|
138
|
+
container: ui-container
|
|
139
|
+
port: 3000
|
|
140
|
+
healthCheck:
|
|
141
|
+
path: /
|
|
142
|
+
interval: 30
|
|
143
|
+
|
|
144
|
+
nginx:
|
|
145
|
+
configPath: /etc/nginx/sites-available
|
|
146
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
147
|
+
|
|
148
|
+
certbot:
|
|
149
|
+
email: admin@example.com
|
|
150
|
+
staging: false
|
|
151
|
+
|
|
152
|
+
deployment:
|
|
153
|
+
strategy: rolling
|
|
154
|
+
healthCheckTimeout: 30000
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Deployment
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
suthep deploy
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Result
|
|
164
|
+
|
|
165
|
+
- API available at `https://example.com/api`
|
|
166
|
+
- UI available at `https://example.com`
|
|
167
|
+
- Both services share the same domain
|
|
168
|
+
|
|
169
|
+
## Example 4: Multiple Domains for Single Service
|
|
170
|
+
|
|
171
|
+
Route multiple domains to the same service.
|
|
172
|
+
|
|
173
|
+
### Configuration
|
|
174
|
+
|
|
175
|
+
```yaml
|
|
176
|
+
project:
|
|
177
|
+
name: dashboard
|
|
178
|
+
version: 1.0.0
|
|
179
|
+
|
|
180
|
+
services:
|
|
181
|
+
- name: dashboard
|
|
182
|
+
port: 5000
|
|
183
|
+
domains:
|
|
184
|
+
- dashboard.example.com
|
|
185
|
+
- admin.example.com
|
|
186
|
+
- app.example.com
|
|
187
|
+
healthCheck:
|
|
188
|
+
path: /api/health
|
|
189
|
+
interval: 60
|
|
190
|
+
environment:
|
|
191
|
+
DATABASE_URL: postgresql://localhost:5432/dashboard
|
|
192
|
+
REDIS_URL: redis://localhost:6379
|
|
193
|
+
|
|
194
|
+
nginx:
|
|
195
|
+
configPath: /etc/nginx/sites-available
|
|
196
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
197
|
+
|
|
198
|
+
certbot:
|
|
199
|
+
email: admin@example.com
|
|
200
|
+
staging: false
|
|
201
|
+
|
|
202
|
+
deployment:
|
|
203
|
+
strategy: rolling
|
|
204
|
+
healthCheckTimeout: 30000
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Deployment
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
suthep deploy
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Result
|
|
214
|
+
|
|
215
|
+
- Service available at:
|
|
216
|
+
- `https://dashboard.example.com`
|
|
217
|
+
- `https://admin.example.com`
|
|
218
|
+
- `https://app.example.com`
|
|
219
|
+
- All domains route to the same service
|
|
220
|
+
|
|
221
|
+
## Example 5: Connect to Existing Docker Container
|
|
222
|
+
|
|
223
|
+
Connect to an already running Docker container.
|
|
224
|
+
|
|
225
|
+
### Configuration
|
|
226
|
+
|
|
227
|
+
```yaml
|
|
228
|
+
project:
|
|
229
|
+
name: database-proxy
|
|
230
|
+
version: 1.0.0
|
|
231
|
+
|
|
232
|
+
services:
|
|
233
|
+
- name: database-proxy
|
|
234
|
+
port: 5432
|
|
235
|
+
docker:
|
|
236
|
+
container: postgres-container
|
|
237
|
+
port: 5432
|
|
238
|
+
domains:
|
|
239
|
+
- db.example.com
|
|
240
|
+
|
|
241
|
+
nginx:
|
|
242
|
+
configPath: /etc/nginx/sites-available
|
|
243
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
244
|
+
|
|
245
|
+
certbot:
|
|
246
|
+
email: admin@example.com
|
|
247
|
+
staging: false
|
|
248
|
+
|
|
249
|
+
deployment:
|
|
250
|
+
strategy: rolling
|
|
251
|
+
healthCheckTimeout: 30000
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Deployment
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# Ensure container is running
|
|
258
|
+
docker start postgres-container
|
|
259
|
+
|
|
260
|
+
# Deploy
|
|
261
|
+
suthep deploy
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Result
|
|
265
|
+
|
|
266
|
+
- Nginx configured to proxy to existing container
|
|
267
|
+
- No new container created
|
|
268
|
+
|
|
269
|
+
## Example 6: Microservices Architecture
|
|
270
|
+
|
|
271
|
+
Deploy multiple microservices with different domains.
|
|
272
|
+
|
|
273
|
+
### Configuration
|
|
274
|
+
|
|
275
|
+
```yaml
|
|
276
|
+
project:
|
|
277
|
+
name: microservices-platform
|
|
278
|
+
version: 1.0.0
|
|
279
|
+
|
|
280
|
+
services:
|
|
281
|
+
# User service
|
|
282
|
+
- name: user-service
|
|
283
|
+
port: 3001
|
|
284
|
+
domains:
|
|
285
|
+
- users.api.example.com
|
|
286
|
+
docker:
|
|
287
|
+
image: myapp/user-service:latest
|
|
288
|
+
container: user-service-container
|
|
289
|
+
port: 3001
|
|
290
|
+
healthCheck:
|
|
291
|
+
path: /health
|
|
292
|
+
interval: 30
|
|
293
|
+
|
|
294
|
+
# Product service
|
|
295
|
+
- name: product-service
|
|
296
|
+
port: 3002
|
|
297
|
+
domains:
|
|
298
|
+
- products.api.example.com
|
|
299
|
+
docker:
|
|
300
|
+
image: myapp/product-service:latest
|
|
301
|
+
container: product-service-container
|
|
302
|
+
port: 3002
|
|
303
|
+
healthCheck:
|
|
304
|
+
path: /health
|
|
305
|
+
interval: 30
|
|
306
|
+
|
|
307
|
+
# Order service
|
|
308
|
+
- name: order-service
|
|
309
|
+
port: 3003
|
|
310
|
+
domains:
|
|
311
|
+
- orders.api.example.com
|
|
312
|
+
docker:
|
|
313
|
+
image: myapp/order-service:latest
|
|
314
|
+
container: order-service-container
|
|
315
|
+
port: 3003
|
|
316
|
+
healthCheck:
|
|
317
|
+
path: /health
|
|
318
|
+
interval: 30
|
|
319
|
+
|
|
320
|
+
nginx:
|
|
321
|
+
configPath: /etc/nginx/sites-available
|
|
322
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
323
|
+
|
|
324
|
+
certbot:
|
|
325
|
+
email: admin@example.com
|
|
326
|
+
staging: false
|
|
327
|
+
|
|
328
|
+
deployment:
|
|
329
|
+
strategy: rolling
|
|
330
|
+
healthCheckTimeout: 30000
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Deployment
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
suthep deploy
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Result
|
|
340
|
+
|
|
341
|
+
- Each microservice has its own subdomain
|
|
342
|
+
- Independent deployment and scaling
|
|
343
|
+
- All services have automatic HTTPS
|
|
344
|
+
|
|
345
|
+
## Example 7: Development Environment
|
|
346
|
+
|
|
347
|
+
Deploy with staging SSL certificates for testing.
|
|
348
|
+
|
|
349
|
+
### Configuration
|
|
350
|
+
|
|
351
|
+
```yaml
|
|
352
|
+
project:
|
|
353
|
+
name: dev-app
|
|
354
|
+
version: 0.1.0
|
|
355
|
+
|
|
356
|
+
services:
|
|
357
|
+
- name: api
|
|
358
|
+
port: 3000
|
|
359
|
+
domains:
|
|
360
|
+
- api.dev.example.com
|
|
361
|
+
healthCheck:
|
|
362
|
+
path: /health
|
|
363
|
+
interval: 60
|
|
364
|
+
|
|
365
|
+
nginx:
|
|
366
|
+
configPath: /etc/nginx/sites-available
|
|
367
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
368
|
+
|
|
369
|
+
certbot:
|
|
370
|
+
email: dev@example.com
|
|
371
|
+
staging: true # Use staging for testing
|
|
372
|
+
|
|
373
|
+
deployment:
|
|
374
|
+
strategy: rolling
|
|
375
|
+
healthCheckTimeout: 30000
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Deployment
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
suthep deploy
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### Result
|
|
385
|
+
|
|
386
|
+
- Uses Let's Encrypt staging environment
|
|
387
|
+
- No rate limits for testing
|
|
388
|
+
- Can test SSL without affecting production
|
|
389
|
+
|
|
390
|
+
## Example 8: Blue-Green Deployment
|
|
391
|
+
|
|
392
|
+
Use blue-green deployment strategy for zero downtime.
|
|
393
|
+
|
|
394
|
+
### Configuration
|
|
395
|
+
|
|
396
|
+
```yaml
|
|
397
|
+
project:
|
|
398
|
+
name: production-app
|
|
399
|
+
version: 2.0.0
|
|
400
|
+
|
|
401
|
+
services:
|
|
402
|
+
- name: api
|
|
403
|
+
port: 3000
|
|
404
|
+
domains:
|
|
405
|
+
- api.example.com
|
|
406
|
+
docker:
|
|
407
|
+
image: myapp/api:v2.0.0
|
|
408
|
+
container: api-container
|
|
409
|
+
port: 3000
|
|
410
|
+
healthCheck:
|
|
411
|
+
path: /health
|
|
412
|
+
interval: 30
|
|
413
|
+
|
|
414
|
+
nginx:
|
|
415
|
+
configPath: /etc/nginx/sites-available
|
|
416
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
417
|
+
|
|
418
|
+
certbot:
|
|
419
|
+
email: admin@example.com
|
|
420
|
+
staging: false
|
|
421
|
+
|
|
422
|
+
deployment:
|
|
423
|
+
strategy: blue-green # Use blue-green deployment
|
|
424
|
+
healthCheckTimeout: 30000
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### Deployment
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
suthep deploy
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Result
|
|
434
|
+
|
|
435
|
+
- Creates new container alongside old one
|
|
436
|
+
- Switches traffic to new container
|
|
437
|
+
- Removes old container after switch
|
|
438
|
+
- Zero downtime during deployment
|
|
439
|
+
|
|
440
|
+
## Best Practices from Examples
|
|
441
|
+
|
|
442
|
+
1. **Use descriptive service names** - Makes configuration easier to understand
|
|
443
|
+
2. **Set appropriate health check intervals** - Balance between responsiveness and load
|
|
444
|
+
3. **Use staging for development** - Avoid rate limits during testing
|
|
445
|
+
4. **Group related services** - Organize by domain or functionality
|
|
446
|
+
5. **Use path-based routing** - Efficiently use single domain for multiple services
|
|
447
|
+
|
|
448
|
+
## Next Steps
|
|
449
|
+
|
|
450
|
+
- [Troubleshooting](./07-troubleshooting.md) - Common issues and solutions
|
|
451
|
+
- [Advanced Topics](./08-advanced.md) - Advanced configuration options
|
|
452
|
+
|
|
453
|
+
---
|
|
454
|
+
|
|
455
|
+
**Previous:** [Commands Reference](./05-commands.md) | **Next:** [Troubleshooting →](./07-troubleshooting.md)
|
|
456
|
+
|