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
@@ -1,441 +0,0 @@
1
- # Troubleshooting
2
-
3
- This guide helps you resolve common issues when using Suthep.
4
-
5
- ## Common Issues
6
-
7
- ### Permission Denied Errors
8
-
9
- **Problem**: Getting "Permission denied" or "EACCES" errors.
10
-
11
- **Solutions**:
12
- 1. Ensure you have `sudo` access:
13
- ```bash
14
- sudo -v
15
- ```
16
-
17
- 2. For Nginx operations, Suthep requires sudo. Make sure you're running commands that need it with appropriate permissions.
18
-
19
- 3. Check file permissions:
20
- ```bash
21
- ls -la /etc/nginx/sites-available
22
- ```
23
-
24
- ### Nginx Not Found
25
-
26
- **Problem**: `nginx: command not found`
27
-
28
- **Solutions**:
29
- 1. Run the setup command:
30
- ```bash
31
- suthep setup --nginx-only
32
- ```
33
-
34
- 2. If setup fails, install manually:
35
- ```bash
36
- # Ubuntu/Debian
37
- sudo apt-get update
38
- sudo apt-get install nginx
39
-
40
- # RHEL/CentOS
41
- sudo yum install nginx
42
-
43
- # macOS
44
- brew install nginx
45
- ```
46
-
47
- 3. Verify installation:
48
- ```bash
49
- nginx -v
50
- ```
51
-
52
- ### Certbot Not Found
53
-
54
- **Problem**: `certbot: command not found`
55
-
56
- **Solutions**:
57
- 1. Run the setup command:
58
- ```bash
59
- suthep setup --certbot-only
60
- ```
61
-
62
- 2. If setup fails, install manually:
63
- ```bash
64
- # Ubuntu/Debian
65
- sudo apt-get update
66
- sudo apt-get install certbot python3-certbot-nginx
67
-
68
- # RHEL/CentOS
69
- sudo yum install certbot python3-certbot-nginx
70
-
71
- # macOS
72
- brew install certbot
73
- ```
74
-
75
- 3. Verify installation:
76
- ```bash
77
- certbot --version
78
- ```
79
-
80
- ### SSL Certificate Request Failed
81
-
82
- **Problem**: Certificate request fails with errors like "Failed to obtain SSL certificate"
83
-
84
- **Common Causes**:
85
- 1. **Domain not pointing to server**: DNS not configured correctly
86
- 2. **Port 80 blocked**: Firewall blocking HTTP traffic
87
- 3. **Rate limits**: Too many certificate requests (use staging mode)
88
- 4. **Domain already has certificate**: Certificate already exists
89
-
90
- **Solutions**:
91
- 1. **Check DNS**:
92
- ```bash
93
- dig example.com
94
- # Should return your server's IP
95
- ```
96
-
97
- 2. **Check firewall**:
98
- ```bash
99
- sudo ufw status
100
- # Ensure ports 80 and 443 are open
101
- sudo ufw allow 80
102
- sudo ufw allow 443
103
- ```
104
-
105
- 3. **Use staging mode** for testing:
106
- ```yaml
107
- certbot:
108
- staging: true
109
- ```
110
-
111
- 4. **Check existing certificates**:
112
- ```bash
113
- sudo certbot certificates
114
- ```
115
-
116
- 5. **Revoke and retry** (if needed):
117
- ```bash
118
- sudo certbot revoke -d example.com
119
- ```
120
-
121
- ### Nginx Configuration Test Fails
122
-
123
- **Problem**: `nginx -t` fails with syntax errors
124
-
125
- **Solutions**:
126
- 1. Check the generated Nginx config:
127
- ```bash
128
- sudo cat /etc/nginx/sites-available/service-name.conf
129
- ```
130
-
131
- 2. Test Nginx configuration manually:
132
- ```bash
133
- sudo nginx -t
134
- ```
135
-
136
- 3. Check Nginx error logs:
137
- ```bash
138
- sudo tail -f /var/log/nginx/error.log
139
- ```
140
-
141
- 4. Common issues:
142
- - Missing SSL certificates (if HTTPS enabled)
143
- - Invalid domain names
144
- - Port conflicts
145
-
146
- ### Service Health Check Fails
147
-
148
- **Problem**: Health check times out or fails
149
-
150
- **Solutions**:
151
- 1. **Verify service is running**:
152
- ```bash
153
- curl http://localhost:PORT/health
154
- ```
155
-
156
- 2. **Check service logs**:
157
- ```bash
158
- # For Docker containers
159
- docker logs container-name
160
-
161
- # For Node.js services
162
- # Check your application logs
163
- ```
164
-
165
- 3. **Verify health check path**:
166
- - Ensure the path in configuration matches your service endpoint
167
- - Test the endpoint manually
168
-
169
- 4. **Increase timeout**:
170
- ```yaml
171
- deployment:
172
- healthCheckTimeout: 60000 # Increase to 60 seconds
173
- ```
174
-
175
- 5. **Check service is listening on correct port**:
176
- ```bash
177
- netstat -tuln | grep PORT
178
- # or
179
- ss -tuln | grep PORT
180
- ```
181
-
182
- ### Docker Container Issues
183
-
184
- **Problem**: Docker container fails to start or connect
185
-
186
- **Solutions**:
187
- 1. **Check Docker is running**:
188
- ```bash
189
- docker ps
190
- ```
191
-
192
- 2. **Check container exists**:
193
- ```bash
194
- docker ps -a | grep container-name
195
- ```
196
-
197
- 3. **Check container logs**:
198
- ```bash
199
- docker logs container-name
200
- ```
201
-
202
- 4. **Verify port mapping**:
203
- - Ensure host port doesn't conflict with other services
204
- - Check if port is already in use:
205
- ```bash
206
- lsof -i :PORT
207
- ```
208
-
209
- 5. **Check Docker image exists**:
210
- ```bash
211
- docker images | grep image-name
212
- ```
213
-
214
- 6. **Pull image manually** (if needed):
215
- ```bash
216
- docker pull image-name:tag
217
- ```
218
-
219
- ### Domain Not Resolving
220
-
221
- **Problem**: Can't access service via domain name
222
-
223
- **Solutions**:
224
- 1. **Check DNS configuration**:
225
- ```bash
226
- dig example.com
227
- nslookup example.com
228
- ```
229
-
230
- 2. **Verify DNS points to server**:
231
- - Check your DNS provider settings
232
- - Ensure A record points to your server's IP
233
-
234
- 3. **Test locally** (add to /etc/hosts for testing):
235
- ```bash
236
- sudo echo "127.0.0.1 example.com" >> /etc/hosts
237
- ```
238
-
239
- 4. **Check Nginx is serving the domain**:
240
- ```bash
241
- curl -H "Host: example.com" http://localhost
242
- ```
243
-
244
- ### Port Already in Use
245
-
246
- **Problem**: Port conflict errors
247
-
248
- **Solutions**:
249
- 1. **Find what's using the port**:
250
- ```bash
251
- sudo lsof -i :PORT
252
- # or
253
- sudo netstat -tulpn | grep PORT
254
- ```
255
-
256
- 2. **Stop conflicting service** or change port in configuration
257
-
258
- 3. **For Docker containers**, check if port mapping conflicts:
259
- ```bash
260
- docker ps | grep PORT
261
- ```
262
-
263
- ### Nginx Site Not Enabled
264
-
265
- **Problem**: Service not accessible even though deployment succeeded
266
-
267
- **Solutions**:
268
- 1. **Check if site is enabled**:
269
- ```bash
270
- ls -la /etc/nginx/sites-enabled/ | grep service-name
271
- ```
272
-
273
- 2. **Manually enable site**:
274
- ```bash
275
- sudo ln -s /etc/nginx/sites-available/service-name.conf /etc/nginx/sites-enabled/
276
- ```
277
-
278
- 3. **Reload Nginx**:
279
- ```bash
280
- sudo nginx -t
281
- sudo systemctl reload nginx
282
- ```
283
-
284
- ### Configuration File Not Found
285
-
286
- **Problem**: `Configuration file not found: suthep.yml`
287
-
288
- **Solutions**:
289
- 1. **Check current directory**:
290
- ```bash
291
- pwd
292
- ls -la suthep.yml
293
- ```
294
-
295
- 2. **Specify custom path**:
296
- ```bash
297
- suthep deploy -f /path/to/config.yml
298
- ```
299
-
300
- 3. **Create configuration**:
301
- ```bash
302
- suthep init
303
- ```
304
-
305
- ### Service Deployment Fails Midway
306
-
307
- **Problem**: Deployment fails for one service, affecting others
308
-
309
- **Solutions**:
310
- 1. **Check error message** - it will indicate which service failed
311
-
312
- 2. **Fix the issue** for the failing service
313
-
314
- 3. **Redeploy**:
315
- ```bash
316
- suthep deploy
317
- ```
318
-
319
- 4. **Note**: Suthep uses fail-fast, so if one service fails, deployment stops. Previous services remain deployed.
320
-
321
- ### SSL Certificate Expired
322
-
323
- **Problem**: SSL certificate has expired
324
-
325
- **Solutions**:
326
- 1. **Check certificate expiration**:
327
- ```bash
328
- sudo certbot certificates
329
- ```
330
-
331
- 2. **Renew certificates**:
332
- ```bash
333
- sudo certbot renew
334
- ```
335
-
336
- 3. **Set up auto-renewal** (recommended):
337
- ```bash
338
- # Add to crontab
339
- sudo crontab -e
340
- # Add: 0 0 * * * certbot renew --quiet
341
- ```
342
-
343
- ### Multiple Services on Same Port
344
-
345
- **Problem**: Two services configured with the same port
346
-
347
- **Solutions**:
348
- 1. **Use different ports** for each service:
349
- ```yaml
350
- services:
351
- - name: api
352
- port: 3000
353
- - name: webapp
354
- port: 3001 # Different port
355
- ```
356
-
357
- 2. **Use Docker port mapping** to map different host ports to same container port
358
-
359
- ## Debugging Tips
360
-
361
- ### Enable Verbose Logging
362
-
363
- Check Nginx and application logs:
364
-
365
- ```bash
366
- # Nginx access logs
367
- sudo tail -f /var/log/nginx/service-name_access.log
368
-
369
- # Nginx error logs
370
- sudo tail -f /var/log/nginx/service-name_error.log
371
-
372
- # Nginx general error log
373
- sudo tail -f /var/log/nginx/error.log
374
- ```
375
-
376
- ### Test Nginx Configuration
377
-
378
- ```bash
379
- # Test configuration syntax
380
- sudo nginx -t
381
-
382
- # Test specific config file
383
- sudo nginx -t -c /etc/nginx/sites-available/service-name.conf
384
- ```
385
-
386
- ### Verify Service Endpoints
387
-
388
- ```bash
389
- # Test health endpoint
390
- curl http://localhost:PORT/health
391
-
392
- # Test main endpoint
393
- curl http://localhost:PORT/
394
-
395
- # Test via domain (if DNS configured)
396
- curl http://example.com
397
- ```
398
-
399
- ### Check Docker Status
400
-
401
- ```bash
402
- # List all containers
403
- docker ps -a
404
-
405
- # Check container status
406
- docker inspect container-name
407
-
408
- # View container logs
409
- docker logs -f container-name
410
- ```
411
-
412
- ### Verify SSL Certificates
413
-
414
- ```bash
415
- # List all certificates
416
- sudo certbot certificates
417
-
418
- # Check certificate details
419
- sudo openssl x509 -in /etc/letsencrypt/live/domain.com/cert.pem -text -noout
420
- ```
421
-
422
- ## Getting Help
423
-
424
- If you're still experiencing issues:
425
-
426
- 1. **Check logs**: Review Nginx, Docker, and application logs
427
- 2. **Verify configuration**: Ensure `suthep.yml` is valid YAML
428
- 3. **Test components individually**: Test Nginx, Certbot, and Docker separately
429
- 4. **Review documentation**: Check [Configuration Reference](./configuration.md) and [Examples](./examples.md)
430
- 5. **Check system requirements**: Ensure all prerequisites are installed
431
-
432
- ## Prevention
433
-
434
- To avoid common issues:
435
-
436
- 1. **Use staging certificates** during development
437
- 2. **Test health endpoints** before deployment
438
- 3. **Verify DNS** before requesting certificates
439
- 4. **Check port availability** before deployment
440
- 5. **Backup configurations** before making changes
441
- 6. **Monitor logs** during and after deployment
@@ -1,72 +0,0 @@
1
- version: "3.8"
2
-
3
- services:
4
- # Example 2: Docker container service from example.yml
5
- webapp:
6
- image: nginx:latest
7
- container_name: webapp-container
8
- ports:
9
- - "8080:80"
10
- networks:
11
- - suthep-network
12
- healthcheck:
13
- test: ["CMD", "curl", "-f", "http://localhost/"]
14
- interval: 30s
15
- timeout: 10s
16
- retries: 3
17
- restart: unless-stopped
18
-
19
- # Example 3: Multiple subdomains with Docker from example.yml
20
- dashboard:
21
- image: myapp/dashboard:latest
22
- container_name: dashboard-container
23
- ports:
24
- - "5000:5000"
25
- networks:
26
- - suthep-network
27
- environment:
28
- DATABASE_URL: postgresql://postgres:5432/dashboard
29
- REDIS_URL: redis://redis:6379
30
- healthcheck:
31
- test: ["CMD", "curl", "-f", "http://localhost:5000/api/health"]
32
- interval: 60s
33
- timeout: 10s
34
- retries: 3
35
- depends_on:
36
- - postgres
37
- - redis
38
- restart: unless-stopped
39
-
40
- # Database service for database-proxy example
41
- postgres:
42
- image: postgres:latest
43
- container_name: postgres-container
44
- ports:
45
- - "5432:5432"
46
- networks:
47
- - suthep-network
48
- environment:
49
- POSTGRES_DB: dashboard
50
- POSTGRES_USER: postgres
51
- POSTGRES_PASSWORD: postgres
52
- volumes:
53
- - postgres-data:/var/lib/postgresql/data
54
- restart: unless-stopped
55
-
56
- # Redis service for dashboard
57
- redis:
58
- image: redis:latest
59
- container_name: redis-container
60
- ports:
61
- - "6379:6379"
62
- networks:
63
- - suthep-network
64
- restart: unless-stopped
65
-
66
- networks:
67
- suthep-network:
68
- driver: bridge
69
-
70
- volumes:
71
- postgres-data:
72
-
@@ -1,31 +0,0 @@
1
- project:
2
- name: my-app
3
- version: 1.0.0
4
-
5
- services:
6
-
7
- # Example 2: Docker container service
8
- - name: webapp
9
- port: 3000
10
- docker:
11
- image: frontend-api:latest
12
- container: webapp-container
13
- port: 80
14
- domains:
15
- - example.com
16
- - www.example.com
17
- healthCheck:
18
- path: /
19
- interval: 30
20
-
21
- nginx:
22
- configPath: /etc/nginx/sites-available
23
- reloadCommand: sudo nginx -t && sudo systemctl reload nginx
24
-
25
- certbot:
26
- email: admin@example.com
27
- staging: true # Set to true for testing
28
-
29
- deployment:
30
- strategy: rolling # Options: rolling, blue-green
31
- healthCheckTimeout: 30000 # milliseconds