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.
Files changed (72) hide show
  1. package/README.md +172 -71
  2. package/dist/commands/deploy.js +251 -37
  3. package/dist/commands/deploy.js.map +1 -1
  4. package/dist/commands/down.js +179 -0
  5. package/dist/commands/down.js.map +1 -0
  6. package/dist/commands/redeploy.js +59 -0
  7. package/dist/commands/redeploy.js.map +1 -0
  8. package/dist/commands/up.js +213 -0
  9. package/dist/commands/up.js.map +1 -0
  10. package/dist/index.js +36 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/utils/certbot.js +40 -3
  13. package/dist/utils/certbot.js.map +1 -1
  14. package/dist/utils/config-loader.js +30 -0
  15. package/dist/utils/config-loader.js.map +1 -1
  16. package/dist/utils/deployment.js +49 -16
  17. package/dist/utils/deployment.js.map +1 -1
  18. package/dist/utils/docker.js +396 -25
  19. package/dist/utils/docker.js.map +1 -1
  20. package/dist/utils/nginx.js +167 -8
  21. package/dist/utils/nginx.js.map +1 -1
  22. package/docs/README.md +25 -49
  23. package/docs/english/01-introduction.md +84 -0
  24. package/docs/english/02-installation.md +200 -0
  25. package/docs/english/03-quick-start.md +256 -0
  26. package/docs/english/04-configuration.md +358 -0
  27. package/docs/english/05-commands.md +363 -0
  28. package/docs/english/06-examples.md +456 -0
  29. package/docs/english/07-troubleshooting.md +417 -0
  30. package/docs/english/08-advanced.md +411 -0
  31. package/docs/english/README.md +48 -0
  32. package/docs/thai/01-introduction.md +84 -0
  33. package/docs/thai/02-installation.md +200 -0
  34. package/docs/thai/03-quick-start.md +256 -0
  35. package/docs/thai/04-configuration.md +358 -0
  36. package/docs/thai/05-commands.md +363 -0
  37. package/docs/thai/06-examples.md +456 -0
  38. package/docs/thai/07-troubleshooting.md +417 -0
  39. package/docs/thai/08-advanced.md +411 -0
  40. package/docs/thai/README.md +48 -0
  41. package/example/README.md +286 -53
  42. package/example/suthep-complete.yml +103 -0
  43. package/example/suthep-docker-only.yml +71 -0
  44. package/example/suthep-no-docker.yml +51 -0
  45. package/example/suthep-path-routing.yml +62 -0
  46. package/example/suthep.example.yml +89 -0
  47. package/package.json +1 -1
  48. package/src/commands/deploy.ts +322 -50
  49. package/src/commands/down.ts +240 -0
  50. package/src/commands/redeploy.ts +78 -0
  51. package/src/commands/up.ts +271 -0
  52. package/src/index.ts +62 -1
  53. package/src/types/config.ts +25 -24
  54. package/src/utils/certbot.ts +68 -6
  55. package/src/utils/config-loader.ts +40 -0
  56. package/src/utils/deployment.ts +61 -36
  57. package/src/utils/docker.ts +634 -30
  58. package/src/utils/nginx.ts +187 -4
  59. package/suthep-0.1.0-beta.1.tgz +0 -0
  60. package/suthep-0.1.1.tgz +0 -0
  61. package/suthep.example.yml +34 -0
  62. package/suthep.yml +39 -0
  63. package/test +0 -0
  64. package/docs/api-reference.md +0 -545
  65. package/docs/architecture.md +0 -367
  66. package/docs/commands.md +0 -273
  67. package/docs/configuration.md +0 -347
  68. package/docs/examples.md +0 -537
  69. package/docs/getting-started.md +0 -197
  70. package/docs/troubleshooting.md +0 -441
  71. package/example/docker-compose.yml +0 -72
  72. package/example/suthep.yml +0 -31
@@ -0,0 +1,411 @@
1
+ # Advanced Topics
2
+
3
+ This guide covers advanced configuration options and optimization techniques for Suthep.
4
+
5
+ ## Advanced Configuration
6
+
7
+ ### Custom Nginx Configuration
8
+
9
+ While Suthep generates Nginx configurations automatically, you can customize them by editing the generated files:
10
+
11
+ ```bash
12
+ # Edit generated config
13
+ sudo nano /etc/nginx/sites-available/example_com.conf
14
+ ```
15
+
16
+ **Note:** Manual edits may be overwritten on redeployment. Consider using Nginx includes for custom configurations.
17
+
18
+ ### Environment-Specific Configurations
19
+
20
+ Use different configuration files for different environments:
21
+
22
+ ```bash
23
+ # Development
24
+ suthep deploy -f suthep.dev.yml
25
+
26
+ # Staging
27
+ suthep deploy -f suthep.staging.yml
28
+
29
+ # Production
30
+ suthep deploy -f suthep.prod.yml
31
+ ```
32
+
33
+ ### Multiple Deployment Strategies
34
+
35
+ Configure different strategies per service (future feature):
36
+
37
+ ```yaml
38
+ services:
39
+ - name: api
40
+ deployment:
41
+ strategy: blue-green
42
+ - name: webapp
43
+ deployment:
44
+ strategy: rolling
45
+ ```
46
+
47
+ ## Performance Optimization
48
+
49
+ ### Health Check Optimization
50
+
51
+ Optimize health check intervals based on service criticality:
52
+
53
+ ```yaml
54
+ # Critical service - frequent checks
55
+ services:
56
+ - name: payment-api
57
+ healthCheck:
58
+ interval: 15 # Check every 15 seconds
59
+
60
+ # Less critical service - less frequent checks
61
+ services:
62
+ - name: analytics
63
+ healthCheck:
64
+ interval: 120 # Check every 2 minutes
65
+ ```
66
+
67
+ ### Deployment Timeout Tuning
68
+
69
+ Adjust health check timeouts for slow-starting services:
70
+
71
+ ```yaml
72
+ deployment:
73
+ healthCheckTimeout: 60000 # 60 seconds for slow services
74
+ ```
75
+
76
+ ### Resource Management
77
+
78
+ Monitor and manage resources:
79
+
80
+ ```bash
81
+ # Monitor Docker resources
82
+ docker stats
83
+
84
+ # Monitor Nginx connections
85
+ sudo nginx -V # Check worker processes
86
+ ```
87
+
88
+ ## Security Best Practices
89
+
90
+ ### SSL/TLS Configuration
91
+
92
+ Ensure strong SSL configuration:
93
+
94
+ 1. **Use Production Certificates**
95
+ ```yaml
96
+ certbot:
97
+ staging: false # Use production certificates
98
+ ```
99
+
100
+ 2. **Monitor Certificate Expiry**
101
+ ```bash
102
+ sudo certbot certificates
103
+ ```
104
+
105
+ 3. **Set Up Auto-Renewal**
106
+ ```bash
107
+ # Certbot auto-renewal (usually set up automatically)
108
+ sudo certbot renew --dry-run
109
+ ```
110
+
111
+ ### Firewall Configuration
112
+
113
+ Configure firewall rules:
114
+
115
+ ```bash
116
+ # Allow HTTP and HTTPS
117
+ sudo ufw allow 80/tcp
118
+ sudo ufw allow 443/tcp
119
+
120
+ # Deny direct access to service ports
121
+ sudo ufw deny 3000/tcp
122
+ ```
123
+
124
+ ### Container Security
125
+
126
+ Secure Docker containers:
127
+
128
+ ```yaml
129
+ services:
130
+ - name: api
131
+ docker:
132
+ image: myapp/api:latest
133
+ container: api-container
134
+ # Consider adding:
135
+ # - Resource limits
136
+ # - Security options
137
+ # - Network isolation
138
+ ```
139
+
140
+ ## Monitoring and Logging
141
+
142
+ ### Nginx Access Logs
143
+
144
+ Monitor access patterns:
145
+
146
+ ```bash
147
+ # Real-time access monitoring
148
+ sudo tail -f /var/log/nginx/access.log
149
+
150
+ # Analyze access patterns
151
+ sudo cat /var/log/nginx/access.log | grep "GET /api"
152
+ ```
153
+
154
+ ### Docker Container Logs
155
+
156
+ Monitor container logs:
157
+
158
+ ```bash
159
+ # Follow logs
160
+ docker logs -f <container-name>
161
+
162
+ # View last 100 lines
163
+ docker logs --tail 100 <container-name>
164
+
165
+ # Logs with timestamps
166
+ docker logs -t <container-name>
167
+ ```
168
+
169
+ ### Health Check Monitoring
170
+
171
+ Monitor health check status:
172
+
173
+ ```bash
174
+ # Manual health check
175
+ curl http://localhost:3000/health
176
+
177
+ # Automated monitoring script
178
+ while true; do
179
+ curl -f http://localhost:3000/health || echo "Health check failed"
180
+ sleep 30
181
+ done
182
+ ```
183
+
184
+ ## Scaling Strategies
185
+
186
+ ### Horizontal Scaling
187
+
188
+ Deploy multiple instances:
189
+
190
+ ```yaml
191
+ services:
192
+ - name: api
193
+ port: 3000
194
+ instances: 3 # Deploy 3 instances
195
+ domains:
196
+ - api.example.com
197
+ ```
198
+
199
+ **Note:** This is a conceptual example. Current implementation manages single instances per service.
200
+
201
+ ### Load Balancing
202
+
203
+ Use Nginx for load balancing (advanced):
204
+
205
+ ```nginx
206
+ upstream api_backend {
207
+ server localhost:3000;
208
+ server localhost:3001;
209
+ server localhost:3002;
210
+ }
211
+ ```
212
+
213
+ ## Backup and Recovery
214
+
215
+ ### Configuration Backup
216
+
217
+ Backup your configuration:
218
+
219
+ ```bash
220
+ # Backup configuration
221
+ cp suthep.yml suthep.yml.backup
222
+
223
+ # Version control
224
+ git add suthep.yml
225
+ git commit -m "Update deployment configuration"
226
+ ```
227
+
228
+ ### Nginx Configuration Backup
229
+
230
+ Backup Nginx configurations:
231
+
232
+ ```bash
233
+ # Backup all Nginx configs
234
+ sudo tar -czf nginx-configs-backup.tar.gz /etc/nginx/sites-available/
235
+ ```
236
+
237
+ ### Container Backup
238
+
239
+ Backup Docker containers:
240
+
241
+ ```bash
242
+ # Export container
243
+ docker export <container-name> > container-backup.tar
244
+
245
+ # Or commit to image
246
+ docker commit <container-name> backup-image:latest
247
+ ```
248
+
249
+ ## Automation and CI/CD
250
+
251
+ ### Deployment Scripts
252
+
253
+ Create deployment scripts:
254
+
255
+ ```bash
256
+ #!/bin/bash
257
+ # deploy.sh
258
+
259
+ set -e
260
+
261
+ echo "Deploying services..."
262
+
263
+ # Run tests
264
+ npm test
265
+
266
+ # Deploy
267
+ suthep deploy
268
+
269
+ echo "Deployment complete!"
270
+ ```
271
+
272
+ ### CI/CD Integration
273
+
274
+ Example GitHub Actions workflow:
275
+
276
+ ```yaml
277
+ name: Deploy
278
+
279
+ on:
280
+ push:
281
+ branches: [main]
282
+
283
+ jobs:
284
+ deploy:
285
+ runs-on: ubuntu-latest
286
+ steps:
287
+ - uses: actions/checkout@v2
288
+ - uses: actions/setup-node@v2
289
+ with:
290
+ node-version: '16'
291
+ - run: npm install -g suthep
292
+ - run: suthep deploy
293
+ env:
294
+ SSH_KEY: ${{ secrets.SSH_KEY }}
295
+ ```
296
+
297
+ ## Advanced Docker Usage
298
+
299
+ ### Multi-Stage Builds
300
+
301
+ Use multi-stage builds for optimized images:
302
+
303
+ ```dockerfile
304
+ # Build stage
305
+ FROM node:16 AS builder
306
+ WORKDIR /app
307
+ COPY package*.json ./
308
+ RUN npm install
309
+ COPY . .
310
+ RUN npm run build
311
+
312
+ # Production stage
313
+ FROM node:16-alpine
314
+ WORKDIR /app
315
+ COPY --from=builder /app/dist ./dist
316
+ COPY --from=builder /app/node_modules ./node_modules
317
+ CMD ["node", "dist/index.js"]
318
+ ```
319
+
320
+ ### Docker Compose Integration
321
+
322
+ Use Docker Compose alongside Suthep:
323
+
324
+ ```yaml
325
+ # docker-compose.yml
326
+ version: '3'
327
+ services:
328
+ database:
329
+ image: postgres:14
330
+ # ... database config
331
+ ```
332
+
333
+ Then connect Suthep to the container:
334
+
335
+ ```yaml
336
+ services:
337
+ - name: api
338
+ docker:
339
+ container: myapp_database_1 # From docker-compose
340
+ port: 5432
341
+ ```
342
+
343
+ ## Troubleshooting Advanced Issues
344
+
345
+ ### Performance Debugging
346
+
347
+ Identify performance bottlenecks:
348
+
349
+ ```bash
350
+ # Monitor Nginx performance
351
+ sudo nginx -V # Check compiled modules
352
+ sudo nginx -T # Test and show full config
353
+
354
+ # Monitor system resources
355
+ htop
356
+ iostat
357
+ ```
358
+
359
+ ### Network Debugging
360
+
361
+ Debug network issues:
362
+
363
+ ```bash
364
+ # Check port binding
365
+ sudo netstat -tulpn | grep 3000
366
+
367
+ # Test connectivity
368
+ curl -v http://localhost:3000
369
+
370
+ # Check DNS
371
+ dig example.com
372
+ nslookup example.com
373
+ ```
374
+
375
+ ### Container Debugging
376
+
377
+ Debug container issues:
378
+
379
+ ```bash
380
+ # Inspect container
381
+ docker inspect <container-name>
382
+
383
+ # Execute commands in container
384
+ docker exec -it <container-name> /bin/sh
385
+
386
+ # Check container network
387
+ docker network ls
388
+ docker network inspect bridge
389
+ ```
390
+
391
+ ## Best Practices Summary
392
+
393
+ 1. **Use Version Control** - Track configuration changes
394
+ 2. **Test in Staging** - Always test before production
395
+ 3. **Monitor Health Checks** - Set appropriate intervals
396
+ 4. **Backup Configurations** - Regular backups
397
+ 5. **Secure Access** - Use HTTPS, configure firewalls
398
+ 6. **Optimize Resources** - Monitor and optimize usage
399
+ 7. **Document Changes** - Keep deployment logs
400
+ 8. **Automate Deployments** - Use CI/CD pipelines
401
+
402
+ ## Next Steps
403
+
404
+ - Review [Examples](./06-examples.md) for practical use cases
405
+ - Check [Troubleshooting](./07-troubleshooting.md) for common issues
406
+ - Refer to [Configuration Guide](./04-configuration.md) for all options
407
+
408
+ ---
409
+
410
+ **Previous:** [Troubleshooting](./07-troubleshooting.md) | **Back to:** [README](./README.md)
411
+
@@ -0,0 +1,48 @@
1
+ # Suthep User Guide
2
+
3
+ Welcome to the Suthep user guide! This comprehensive guide will help you understand and use Suthep to deploy your projects with ease.
4
+
5
+ ## Table of Contents
6
+
7
+ 1. [Introduction](./01-introduction.md)
8
+ 2. [Installation](./02-installation.md)
9
+ 3. [Quick Start](./03-quick-start.md)
10
+ 4. [Configuration Guide](./04-configuration.md)
11
+ 5. [Commands Reference](./05-commands.md)
12
+ 6. [Examples](./06-examples.md)
13
+ 7. [Troubleshooting](./07-troubleshooting.md)
14
+ 8. [Advanced Topics](./08-advanced.md)
15
+
16
+ ## What is Suthep?
17
+
18
+ Suthep is a powerful CLI tool for deploying projects with automatic Nginx reverse proxy setup, HTTPS with Certbot, and zero-downtime deployments. It simplifies the deployment process by automating complex infrastructure tasks.
19
+
20
+ ## Key Features
21
+
22
+ - ✅ **Automatic Nginx Reverse Proxy** - Configures Nginx automatically for your services
23
+ - ✅ **Automatic HTTPS** - Sets up SSL/TLS certificates with Let's Encrypt via Certbot
24
+ - ✅ **Zero-Downtime Deployment** - Rolling deployment strategy ensures continuous availability
25
+ - ✅ **Docker Support** - Deploy Docker containers or connect to existing containers
26
+ - ✅ **Multiple Domains** - Support for multiple domains and subdomains per service
27
+ - ✅ **Health Checks** - Built-in health check monitoring for service reliability
28
+ - ✅ **YAML Configuration** - Simple, declarative configuration file format
29
+
30
+ ## Quick Navigation
31
+
32
+ - **New to Suthep?** Start with [Introduction](./01-introduction.md) and [Quick Start](./03-quick-start.md)
33
+ - **Need help with configuration?** Check [Configuration Guide](./04-configuration.md)
34
+ - **Looking for examples?** See [Examples](./06-examples.md)
35
+ - **Having issues?** Visit [Troubleshooting](./07-troubleshooting.md)
36
+
37
+ ## Getting Help
38
+
39
+ If you encounter any issues or have questions:
40
+
41
+ 1. Check the [Troubleshooting](./07-troubleshooting.md) section
42
+ 2. Review the [Examples](./06-examples.md) for common use cases
43
+ 3. Consult the [Commands Reference](./05-commands.md) for detailed command documentation
44
+
45
+ ---
46
+
47
+ **Next:** [Introduction →](./01-introduction.md)
48
+
@@ -0,0 +1,84 @@
1
+ # บทนำ Suthep
2
+
3
+ ## Suthep คืออะไร?
4
+
5
+ Suthep เป็นเครื่องมือ command-line ที่ออกแบบมาเพื่อทำให้การ deploy เว็บแอปพลิเคชันและบริการง่ายขึ้น มันทำให้กระบวนการที่ซับซ้อนของการตั้งค่า reverse proxy, ใบรับรอง SSL, และการจัดการการ deploy แบบ zero downtime เป็นอัตโนมัติ
6
+
7
+ ## ทำไมต้องใช้ Suthep?
8
+
9
+ ### การ Deploy ที่เรียบง่าย
10
+
11
+ กระบวนการ deploy แบบดั้งเดิมต้องตั้งค่าด้วยตนเอง:
12
+ - กฎ Nginx reverse proxy
13
+ - การจัดการใบรับรอง SSL
14
+ - การจัดการ Docker container orchestration
15
+ - การตรวจสอบ health check
16
+ - กลยุทธ์การ deploy แบบ zero-downtime
17
+
18
+ Suthep จัดการทั้งหมดนี้ให้อัตโนมัติด้วยไฟล์การตั้งค่า YAML ที่เรียบง่าย
19
+
20
+ ### ประโยชน์หลัก
21
+
22
+ 1. **ประหยัดเวลา** - Deploy ในไม่กี่นาทีแทนที่จะเป็นชั่วโมง
23
+ 2. **ลดข้อผิดพลาด** - การตั้งค่าอัตโนมัติลดข้อผิดพลาดของมนุษย์
24
+ 3. **Zero Downtime** - การ deploy แบบ rolling ทำให้บริการพร้อมใช้งานอย่างต่อเนื่อง
25
+ 4. **จัดการง่าย** - คำสั่งง่ายๆ ในการ deploy, อัปเดต, และจัดการบริการ
26
+ 5. **ประหยัดต้นทุน** - รันหลายบริการบนเซิร์ฟเวอร์เดียวอย่างมีประสิทธิภาพ
27
+
28
+ ## วิธีการทำงาน
29
+
30
+ Suthep ทำงานตามขั้นตอนง่ายๆ:
31
+
32
+ 1. **ตั้งค่า** - สร้างไฟล์การตั้งค่า `suthep.yml`
33
+ 2. **Setup** - ติดตั้งสิ่งที่จำเป็น (Nginx, Certbot) ด้วย `suthep setup`
34
+ 3. **Deploy** - Deploy บริการของคุณด้วย `suthep deploy`
35
+
36
+ เบื้องหลัง Suthep:
37
+ - สร้างไฟล์การตั้งค่า Nginx
38
+ - รับใบรับรอง SSL จาก Let's Encrypt
39
+ - จัดการ Docker containers
40
+ - ทำ health checks
41
+ - จัดการการ deploy แบบ zero-downtime
42
+
43
+ ## กรณีการใช้งาน
44
+
45
+ Suthep เหมาะสำหรับ:
46
+
47
+ - **แอปพลิเคชันขนาดเล็กถึงกลาง** - Deploy หลายบริการบนเซิร์ฟเวอร์เดียว
48
+ - **Microservices** - จัดการหลายบริการที่มีโดเมนต่างกัน
49
+ - **แอปพลิเคชัน Docker** - Deploy แอปพลิเคชันที่ใช้ container ได้ง่าย
50
+ - **บริการ API** - ตั้งค่า reverse proxy สำหรับ API endpoints
51
+ - **เว็บแอปพลิเคชัน** - Deploy เว็บแอปพร้อม HTTPS อัตโนมัติ
52
+
53
+ ## สิ่งที่คุณจะได้เรียนรู้
54
+
55
+ ในคู่มือนี้ คุณจะได้เรียนรู้:
56
+
57
+ - วิธีการติดตั้งและตั้งค่า Suthep
58
+ - วิธีการสร้างและตั้งค่าไฟล์ deployment
59
+ - วิธีการใช้คำสั่งทั้งหมดที่มี
60
+ - วิธีการ deploy ประเภทบริการต่างๆ
61
+ - วิธีการแก้ปัญหาที่พบบ่อย
62
+ - ตัวเลือกการตั้งค่าขั้นสูง
63
+
64
+ ## สิ่งที่ต้องมีก่อนเริ่ม
65
+
66
+ ก่อนใช้ Suthep คุณควรมี:
67
+
68
+ - **Node.js 16+** ติดตั้งแล้ว
69
+ - **sudo/administrator access** บนเซิร์ฟเวอร์ของคุณ
70
+ - **ชื่อโดเมน** ที่ชี้ไปที่เซิร์ฟเวอร์ของคุณ (สำหรับ HTTPS)
71
+ - **ความรู้พื้นฐาน** เกี่ยวกับไฟล์การตั้งค่า YAML
72
+ - **Docker** (ไม่บังคับ, ใช้เฉพาะเมื่อ deploy Docker containers)
73
+
74
+ ## ขั้นตอนถัดไป
75
+
76
+ พร้อมเริ่มต้นแล้วหรือยัง? ไปต่อที่:
77
+
78
+ - [คู่มือการติดตั้ง](./02-installation.md) - ติดตั้ง Suthep บนระบบของคุณ
79
+ - [คู่มือเริ่มต้นใช้งาน](./03-quick-start.md) - Deploy บริการแรกของคุณ
80
+
81
+ ---
82
+
83
+ **ก่อนหน้า:** [README](./README.md) | **ถัดไป:** [การติดตั้ง →](./02-installation.md)
84
+