suthep 0.1.0-beta.1 → 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 (69) hide show
  1. package/README.md +167 -69
  2. package/dist/commands/down.js +179 -0
  3. package/dist/commands/down.js.map +1 -0
  4. package/dist/commands/redeploy.js +59 -0
  5. package/dist/commands/redeploy.js.map +1 -0
  6. package/dist/commands/up.js +213 -0
  7. package/dist/commands/up.js.map +1 -0
  8. package/dist/index.js +28 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/utils/deployment.js +10 -1
  11. package/dist/utils/deployment.js.map +1 -1
  12. package/dist/utils/docker.js +35 -0
  13. package/dist/utils/docker.js.map +1 -1
  14. package/dist/utils/nginx.js +10 -0
  15. package/dist/utils/nginx.js.map +1 -1
  16. package/docs/README.md +25 -82
  17. package/docs/english/01-introduction.md +84 -0
  18. package/docs/english/02-installation.md +200 -0
  19. package/docs/english/03-quick-start.md +256 -0
  20. package/docs/english/04-configuration.md +358 -0
  21. package/docs/english/05-commands.md +363 -0
  22. package/docs/english/06-examples.md +456 -0
  23. package/docs/english/07-troubleshooting.md +417 -0
  24. package/docs/english/08-advanced.md +411 -0
  25. package/docs/english/README.md +48 -0
  26. package/docs/thai/01-introduction.md +84 -0
  27. package/docs/thai/02-installation.md +200 -0
  28. package/docs/thai/03-quick-start.md +256 -0
  29. package/docs/thai/04-configuration.md +358 -0
  30. package/docs/thai/05-commands.md +363 -0
  31. package/docs/thai/06-examples.md +456 -0
  32. package/docs/thai/07-troubleshooting.md +417 -0
  33. package/docs/thai/08-advanced.md +411 -0
  34. package/docs/thai/README.md +48 -0
  35. package/example/README.md +282 -53
  36. package/example/suthep-complete.yml +103 -0
  37. package/example/suthep-docker-only.yml +71 -0
  38. package/example/suthep-no-docker.yml +51 -0
  39. package/example/{muacle.yml → suthep-path-routing.yml} +20 -5
  40. package/example/suthep.example.yml +89 -0
  41. package/package.json +1 -1
  42. package/src/commands/down.ts +240 -0
  43. package/src/commands/redeploy.ts +78 -0
  44. package/src/commands/up.ts +271 -0
  45. package/src/index.ts +53 -0
  46. package/suthep-0.1.0-beta.1.tgz +0 -0
  47. package/suthep.example.yml +5 -0
  48. package/suthep.yml +39 -0
  49. package/docs/TRANSLATIONS.md +0 -211
  50. package/docs/en/README.md +0 -76
  51. package/docs/en/api-reference.md +0 -545
  52. package/docs/en/architecture.md +0 -369
  53. package/docs/en/commands.md +0 -273
  54. package/docs/en/configuration.md +0 -347
  55. package/docs/en/developer-guide.md +0 -588
  56. package/docs/en/docker-ports-config.md +0 -333
  57. package/docs/en/examples.md +0 -537
  58. package/docs/en/getting-started.md +0 -202
  59. package/docs/en/port-binding.md +0 -268
  60. package/docs/en/troubleshooting.md +0 -441
  61. package/docs/th/README.md +0 -64
  62. package/docs/th/commands.md +0 -202
  63. package/docs/th/configuration.md +0 -325
  64. package/docs/th/getting-started.md +0 -203
  65. package/example/docker-compose.yml +0 -76
  66. package/example/docker-ports-example.yml +0 -81
  67. package/example/port-binding-example.yml +0 -45
  68. package/example/suthep.yml +0 -46
  69. package/example/suthep=1.yml +0 -46
@@ -0,0 +1,256 @@
1
+ # Quick Start Guide
2
+
3
+ This guide will help you deploy your first service with Suthep in just a few minutes.
4
+
5
+ ## Step 1: Initialize Configuration
6
+
7
+ Create a new configuration file interactively:
8
+
9
+ ```bash
10
+ suthep init
11
+ ```
12
+
13
+ This command will prompt you for:
14
+ - Project name and version
15
+ - Service details (name, port, domains)
16
+ - Docker configuration (if needed)
17
+ - Health check settings
18
+ - SSL certificate email
19
+
20
+ Alternatively, you can copy the example configuration:
21
+
22
+ ```bash
23
+ cp suthep.example.yml suthep.yml
24
+ ```
25
+
26
+ Then edit `suthep.yml` with your settings.
27
+
28
+ ## Step 2: Setup Prerequisites
29
+
30
+ Install and configure Nginx and Certbot:
31
+
32
+ ```bash
33
+ suthep setup
34
+ ```
35
+
36
+ This will:
37
+ - Install Nginx (if not already installed)
38
+ - Install Certbot (if not already installed)
39
+ - Configure system dependencies
40
+
41
+ **Note:** This command requires sudo privileges.
42
+
43
+ ## Step 3: Deploy Your Service
44
+
45
+ Deploy your project:
46
+
47
+ ```bash
48
+ suthep deploy
49
+ ```
50
+
51
+ This command will:
52
+ 1. Configure Nginx reverse proxy for all services
53
+ 2. Obtain SSL certificates via Certbot (if enabled)
54
+ 3. Deploy services with zero-downtime strategy
55
+
56
+ ## Example: Deploying a Simple API
57
+
58
+ Let's walk through deploying a Node.js API service:
59
+
60
+ ### 1. Create Configuration
61
+
62
+ Create `suthep.yml`:
63
+
64
+ ```yaml
65
+ project:
66
+ name: my-api
67
+ version: 1.0.0
68
+
69
+ services:
70
+ - name: api
71
+ port: 3000
72
+ domains:
73
+ - api.example.com
74
+ healthCheck:
75
+ path: /health
76
+ interval: 30
77
+ environment:
78
+ NODE_ENV: production
79
+
80
+ nginx:
81
+ configPath: /etc/nginx/sites-available
82
+ reloadCommand: sudo nginx -t && sudo systemctl reload nginx
83
+
84
+ certbot:
85
+ email: admin@example.com
86
+ staging: false
87
+
88
+ deployment:
89
+ strategy: rolling
90
+ healthCheckTimeout: 30000
91
+ ```
92
+
93
+ ### 2. Setup Prerequisites
94
+
95
+ ```bash
96
+ suthep setup
97
+ ```
98
+
99
+ ### 3. Deploy
100
+
101
+ ```bash
102
+ suthep deploy
103
+ ```
104
+
105
+ ### 4. Verify Deployment
106
+
107
+ After deployment, Suthep will display service URLs:
108
+
109
+ ```
110
+ 📋 Service URLs:
111
+ api: https://api.example.com
112
+ ```
113
+
114
+ Visit the URL in your browser to verify the service is running.
115
+
116
+ ## Example: Deploying a Docker Container
117
+
118
+ To deploy a Docker container:
119
+
120
+ ```yaml
121
+ services:
122
+ - name: webapp
123
+ port: 8080
124
+ docker:
125
+ image: nginx:latest
126
+ container: webapp-container
127
+ port: 80
128
+ domains:
129
+ - example.com
130
+ - www.example.com
131
+ ```
132
+
133
+ Then run:
134
+
135
+ ```bash
136
+ suthep deploy
137
+ ```
138
+
139
+ ## Common Commands
140
+
141
+ ### Check Service Status
142
+
143
+ ```bash
144
+ # View Nginx configuration
145
+ sudo nginx -t
146
+
147
+ # Check running containers
148
+ docker ps
149
+
150
+ # View service logs
151
+ docker logs <container-name>
152
+ ```
153
+
154
+ ### Update Configuration
155
+
156
+ 1. Edit `suthep.yml`
157
+ 2. Redeploy:
158
+ ```bash
159
+ suthep redeploy
160
+ ```
161
+
162
+ ### Stop Services
163
+
164
+ ```bash
165
+ # Stop a specific service
166
+ suthep down <service-name>
167
+
168
+ # Stop all services
169
+ suthep down --all
170
+ ```
171
+
172
+ ### Start Services
173
+
174
+ ```bash
175
+ # Start a specific service
176
+ suthep up <service-name>
177
+
178
+ # Start all services
179
+ suthep up --all
180
+ ```
181
+
182
+ ## What Happens During Deployment?
183
+
184
+ When you run `suthep deploy`, Suthep:
185
+
186
+ 1. **Loads Configuration** - Reads your `suthep.yml` file
187
+ 2. **Starts Docker Containers** - If Docker is configured, starts containers
188
+ 3. **Configures Nginx** - Generates and writes Nginx configuration files
189
+ 4. **Enables Sites** - Creates symlinks to enable Nginx sites
190
+ 5. **Obtains SSL Certificates** - Requests certificates from Let's Encrypt
191
+ 6. **Updates Nginx for HTTPS** - Adds SSL configuration to Nginx
192
+ 7. **Reloads Nginx** - Applies all changes
193
+ 8. **Performs Health Checks** - Verifies services are running correctly
194
+
195
+ ## Troubleshooting Quick Start
196
+
197
+ ### Domain Not Resolving
198
+
199
+ Ensure your domain points to your server:
200
+
201
+ ```bash
202
+ # Check DNS
203
+ nslookup api.example.com
204
+
205
+ # Verify server IP matches
206
+ curl -I http://api.example.com
207
+ ```
208
+
209
+ ### Port Already in Use
210
+
211
+ If you get a "port already in use" error:
212
+
213
+ 1. **Find what's using the port:**
214
+ ```bash
215
+ sudo lsof -i :3000
216
+ ```
217
+
218
+ 2. **Stop the conflicting service** or **change the port** in `suthep.yml`
219
+
220
+ ### SSL Certificate Issues
221
+
222
+ If SSL certificate creation fails:
223
+
224
+ 1. **Check domain DNS** - Ensure domain points to your server
225
+ 2. **Use staging mode** for testing:
226
+ ```yaml
227
+ certbot:
228
+ staging: true
229
+ ```
230
+
231
+ 3. **Check firewall** - Ensure ports 80 and 443 are open
232
+
233
+ ### Nginx Configuration Errors
234
+
235
+ If Nginx fails to reload:
236
+
237
+ ```bash
238
+ # Test Nginx configuration
239
+ sudo nginx -t
240
+
241
+ # Check Nginx error logs
242
+ sudo tail -f /var/log/nginx/error.log
243
+ ```
244
+
245
+ ## Next Steps
246
+
247
+ Now that you've deployed your first service:
248
+
249
+ - [Configuration Guide](./04-configuration.md) - Learn about all configuration options
250
+ - [Commands Reference](./05-commands.md) - Explore all available commands
251
+ - [Examples](./06-examples.md) - See more deployment examples
252
+
253
+ ---
254
+
255
+ **Previous:** [Installation](./02-installation.md) | **Next:** [Configuration Guide →](./04-configuration.md)
256
+
@@ -0,0 +1,358 @@
1
+ # Configuration Guide
2
+
3
+ This guide covers all configuration options available in Suthep's `suthep.yml` file.
4
+
5
+ ## Configuration File Structure
6
+
7
+ The `suthep.yml` file uses YAML format and consists of several sections:
8
+
9
+ ```yaml
10
+ project:
11
+ # Project metadata
12
+
13
+ services:
14
+ # Service definitions
15
+
16
+ nginx:
17
+ # Nginx configuration
18
+
19
+ certbot:
20
+ # SSL certificate configuration
21
+
22
+ deployment:
23
+ # Deployment strategy settings
24
+ ```
25
+
26
+ ## Project Configuration
27
+
28
+ The `project` section contains metadata about your project:
29
+
30
+ ```yaml
31
+ project:
32
+ name: my-app # Project name
33
+ version: 1.0.0 # Project version
34
+ ```
35
+
36
+ ### Fields
37
+
38
+ | Field | Required | Description |
39
+ |-------|----------|-------------|
40
+ | `name` | Yes | Unique identifier for your project |
41
+ | `version` | Yes | Project version (for tracking) |
42
+
43
+ ## Services Configuration
44
+
45
+ The `services` array defines all services to deploy. Each service can have multiple configurations.
46
+
47
+ ### Basic Service
48
+
49
+ ```yaml
50
+ services:
51
+ - name: api
52
+ port: 3000
53
+ domains:
54
+ - api.example.com
55
+ ```
56
+
57
+ ### Service Fields
58
+
59
+ | Field | Required | Type | Description |
60
+ |-------|----------|------|-------------|
61
+ | `name` | Yes | string | Unique service identifier |
62
+ | `port` | Yes | number | Port number the service runs on (host port) |
63
+ | `domains` | Yes | array | Array of domain names for this service |
64
+ | `path` | No | string | URL path prefix (default: `/`) |
65
+ | `docker` | No | object | Docker configuration (see below) |
66
+ | `healthCheck` | No | object | Health check configuration (see below) |
67
+ | `environment` | No | object | Environment variables as key-value pairs |
68
+
69
+ ### Docker Configuration
70
+
71
+ Configure Docker container deployment:
72
+
73
+ ```yaml
74
+ services:
75
+ - name: webapp
76
+ port: 8080
77
+ docker:
78
+ image: nginx:latest # Docker image to pull
79
+ container: webapp-container # Container name
80
+ port: 80 # Container internal port
81
+ ```
82
+
83
+ #### Docker Fields
84
+
85
+ | Field | Required | Description |
86
+ |-------|----------|-------------|
87
+ | `image` | No* | Docker image to pull and run |
88
+ | `container` | Yes | Name for the Docker container |
89
+ | `port` | Yes | Internal port the container listens on |
90
+
91
+ \* `image` is optional if connecting to an existing container.
92
+
93
+ #### Connect to Existing Container
94
+
95
+ To connect to an already running container, omit the `image` field:
96
+
97
+ ```yaml
98
+ services:
99
+ - name: database-proxy
100
+ port: 5432
101
+ docker:
102
+ container: postgres-container
103
+ port: 5432
104
+ ```
105
+
106
+ ### Health Check Configuration
107
+
108
+ Configure health monitoring for your service:
109
+
110
+ ```yaml
111
+ services:
112
+ - name: api
113
+ healthCheck:
114
+ path: /health # Health check endpoint
115
+ interval: 30 # Check interval in seconds
116
+ ```
117
+
118
+ #### Health Check Fields
119
+
120
+ | Field | Required | Default | Description |
121
+ |-------|----------|---------|-------------|
122
+ | `path` | Yes | - | HTTP endpoint path for health checks |
123
+ | `interval` | No | 30 | Time between health checks (seconds) |
124
+
125
+ ### Environment Variables
126
+
127
+ Set environment variables for your service:
128
+
129
+ ```yaml
130
+ services:
131
+ - name: api
132
+ environment:
133
+ NODE_ENV: production
134
+ DATABASE_URL: postgresql://localhost:5432/mydb
135
+ API_KEY: your-api-key
136
+ ```
137
+
138
+ ### Path-Based Routing
139
+
140
+ Route different services on the same domain using paths:
141
+
142
+ ```yaml
143
+ services:
144
+ # API service on /api path
145
+ - name: api
146
+ port: 3001
147
+ path: /api
148
+ domains:
149
+ - example.com
150
+
151
+ # UI service on root path
152
+ - name: ui
153
+ port: 3000
154
+ path: /
155
+ domains:
156
+ - example.com
157
+ ```
158
+
159
+ ## Nginx Configuration
160
+
161
+ Configure Nginx settings:
162
+
163
+ ```yaml
164
+ nginx:
165
+ configPath: /etc/nginx/sites-available
166
+ reloadCommand: sudo nginx -t && sudo systemctl reload nginx
167
+ ```
168
+
169
+ ### Nginx Fields
170
+
171
+ | Field | Required | Default | Description |
172
+ |-------|----------|---------|-------------|
173
+ | `configPath` | No | `/etc/nginx/sites-available` | Path where Nginx configs are stored |
174
+ | `reloadCommand` | No | `sudo nginx -t && sudo systemctl reload nginx` | Command to reload Nginx |
175
+
176
+ ## Certbot Configuration
177
+
178
+ Configure SSL certificate settings:
179
+
180
+ ```yaml
181
+ certbot:
182
+ email: admin@example.com # Email for Let's Encrypt
183
+ staging: false # Use staging environment (for testing)
184
+ ```
185
+
186
+ ### Certbot Fields
187
+
188
+ | Field | Required | Description |
189
+ |-------|----------|-------------|
190
+ | `email` | Yes | Email address for Let's Encrypt notifications |
191
+ | `staging` | No | Use staging environment (default: `false`) |
192
+
193
+ **Note:** Use `staging: true` for testing to avoid rate limits.
194
+
195
+ ## Deployment Configuration
196
+
197
+ Configure deployment strategy:
198
+
199
+ ```yaml
200
+ deployment:
201
+ strategy: rolling # Deployment strategy
202
+ healthCheckTimeout: 30000 # Health check timeout (ms)
203
+ ```
204
+
205
+ ### Deployment Fields
206
+
207
+ | Field | Required | Default | Description |
208
+ |-------|----------|---------|-------------|
209
+ | `strategy` | No | `rolling` | Deployment strategy (`rolling` or `blue-green`) |
210
+ | `healthCheckTimeout` | No | `30000` | Maximum time to wait for health check (milliseconds) |
211
+
212
+ ### Deployment Strategies
213
+
214
+ #### Rolling Deployment
215
+
216
+ Gradually replaces old containers with new ones:
217
+
218
+ ```yaml
219
+ deployment:
220
+ strategy: rolling
221
+ ```
222
+
223
+ #### Blue-Green Deployment
224
+
225
+ Creates new containers, switches traffic, then removes old containers:
226
+
227
+ ```yaml
228
+ deployment:
229
+ strategy: blue-green
230
+ ```
231
+
232
+ ## Complete Configuration Example
233
+
234
+ Here's a complete example with all options:
235
+
236
+ ```yaml
237
+ project:
238
+ name: my-app
239
+ version: 1.0.0
240
+
241
+ services:
242
+ # Simple API service
243
+ - name: api
244
+ port: 3000
245
+ domains:
246
+ - api.example.com
247
+ healthCheck:
248
+ path: /health
249
+ interval: 30
250
+ environment:
251
+ NODE_ENV: production
252
+
253
+ # Docker webapp
254
+ - name: webapp
255
+ port: 8080
256
+ docker:
257
+ image: nginx:latest
258
+ container: webapp-container
259
+ port: 80
260
+ domains:
261
+ - example.com
262
+ - www.example.com
263
+ healthCheck:
264
+ path: /
265
+ interval: 30
266
+
267
+ # Multiple services on same domain
268
+ - name: api-v2
269
+ port: 3001
270
+ path: /api
271
+ domains:
272
+ - example.com
273
+ docker:
274
+ image: myapp/api:latest
275
+ container: api-v2-container
276
+ port: 3001
277
+
278
+ nginx:
279
+ configPath: /etc/nginx/sites-available
280
+ reloadCommand: sudo nginx -t && sudo systemctl reload nginx
281
+
282
+ certbot:
283
+ email: admin@example.com
284
+ staging: false
285
+
286
+ deployment:
287
+ strategy: rolling
288
+ healthCheckTimeout: 30000
289
+ ```
290
+
291
+ ## Configuration Best Practices
292
+
293
+ ### 1. Use Descriptive Service Names
294
+
295
+ ```yaml
296
+ # Good
297
+ - name: user-api
298
+ - name: payment-service
299
+
300
+ # Avoid
301
+ - name: service1
302
+ - name: app
303
+ ```
304
+
305
+ ### 2. Set Appropriate Health Check Intervals
306
+
307
+ ```yaml
308
+ # For critical services
309
+ healthCheck:
310
+ interval: 15 # Check every 15 seconds
311
+
312
+ # For less critical services
313
+ healthCheck:
314
+ interval: 60 # Check every minute
315
+ ```
316
+
317
+ ### 3. Use Staging for Testing
318
+
319
+ ```yaml
320
+ certbot:
321
+ staging: true # Use staging for testing
322
+ ```
323
+
324
+ ### 4. Organize Services by Domain
325
+
326
+ Group related services together in your configuration:
327
+
328
+ ```yaml
329
+ services:
330
+ # API services
331
+ - name: api
332
+ domains: [api.example.com]
333
+ - name: api-v2
334
+ domains: [api-v2.example.com]
335
+
336
+ # Web services
337
+ - name: webapp
338
+ domains: [example.com, www.example.com]
339
+ ```
340
+
341
+ ## Validation
342
+
343
+ Suthep validates your configuration before deployment. Common validation errors:
344
+
345
+ - **Missing required fields** - Ensure all required fields are present
346
+ - **Invalid port numbers** - Ports must be between 1 and 65535
347
+ - **Duplicate service names** - Each service must have a unique name
348
+ - **Invalid domain format** - Domains must be valid hostnames
349
+
350
+ ## Next Steps
351
+
352
+ - [Commands Reference](./05-commands.md) - Learn about all available commands
353
+ - [Examples](./06-examples.md) - See real-world configuration examples
354
+
355
+ ---
356
+
357
+ **Previous:** [Quick Start](./03-quick-start.md) | **Next:** [Commands Reference →](./05-commands.md)
358
+