suthep 0.1.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 (65) hide show
  1. package/.editorconfig +17 -0
  2. package/.prettierignore +6 -0
  3. package/.prettierrc +7 -0
  4. package/.vscode/settings.json +19 -0
  5. package/LICENSE +21 -0
  6. package/README.md +217 -0
  7. package/dist/commands/deploy.js +318 -0
  8. package/dist/commands/deploy.js.map +1 -0
  9. package/dist/commands/init.js +188 -0
  10. package/dist/commands/init.js.map +1 -0
  11. package/dist/commands/setup.js +90 -0
  12. package/dist/commands/setup.js.map +1 -0
  13. package/dist/index.js +19 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/utils/certbot.js +64 -0
  16. package/dist/utils/certbot.js.map +1 -0
  17. package/dist/utils/config-loader.js +95 -0
  18. package/dist/utils/config-loader.js.map +1 -0
  19. package/dist/utils/deployment.js +76 -0
  20. package/dist/utils/deployment.js.map +1 -0
  21. package/dist/utils/docker.js +393 -0
  22. package/dist/utils/docker.js.map +1 -0
  23. package/dist/utils/nginx.js +303 -0
  24. package/dist/utils/nginx.js.map +1 -0
  25. package/docs/README.md +95 -0
  26. package/docs/TRANSLATIONS.md +211 -0
  27. package/docs/en/README.md +76 -0
  28. package/docs/en/api-reference.md +545 -0
  29. package/docs/en/architecture.md +369 -0
  30. package/docs/en/commands.md +273 -0
  31. package/docs/en/configuration.md +347 -0
  32. package/docs/en/developer-guide.md +588 -0
  33. package/docs/en/docker-ports-config.md +333 -0
  34. package/docs/en/examples.md +537 -0
  35. package/docs/en/getting-started.md +202 -0
  36. package/docs/en/port-binding.md +268 -0
  37. package/docs/en/troubleshooting.md +441 -0
  38. package/docs/th/README.md +64 -0
  39. package/docs/th/commands.md +202 -0
  40. package/docs/th/configuration.md +325 -0
  41. package/docs/th/getting-started.md +203 -0
  42. package/example/README.md +85 -0
  43. package/example/docker-compose.yml +76 -0
  44. package/example/docker-ports-example.yml +81 -0
  45. package/example/muacle.yml +47 -0
  46. package/example/port-binding-example.yml +45 -0
  47. package/example/suthep.yml +46 -0
  48. package/example/suthep=1.yml +46 -0
  49. package/package.json +45 -0
  50. package/src/commands/deploy.ts +405 -0
  51. package/src/commands/init.ts +214 -0
  52. package/src/commands/setup.ts +112 -0
  53. package/src/index.ts +42 -0
  54. package/src/types/config.ts +52 -0
  55. package/src/utils/certbot.ts +144 -0
  56. package/src/utils/config-loader.ts +121 -0
  57. package/src/utils/deployment.ts +157 -0
  58. package/src/utils/docker.ts +755 -0
  59. package/src/utils/nginx.ts +326 -0
  60. package/suthep-0.1.1.tgz +0 -0
  61. package/suthep.example.yml +98 -0
  62. package/test +0 -0
  63. package/todo.md +6 -0
  64. package/tsconfig.json +26 -0
  65. package/vite.config.ts +46 -0
@@ -0,0 +1,347 @@
1
+ # Configuration Reference
2
+
3
+ Suthep uses a YAML configuration file (default: `suthep.yml`) to define your deployment. This document describes all available configuration options.
4
+
5
+ ## Configuration File Structure
6
+
7
+ ```yaml
8
+ project:
9
+ name: string
10
+ version: string
11
+
12
+ services:
13
+ - name: string
14
+ port: number
15
+ domains: string[]
16
+ docker?: DockerConfig
17
+ healthCheck?: HealthCheckConfig
18
+ environment?: Record<string, string>
19
+
20
+ nginx:
21
+ configPath: string
22
+ reloadCommand: string
23
+
24
+ certbot:
25
+ email: string
26
+ staging: boolean
27
+
28
+ deployment:
29
+ strategy: 'rolling' | 'blue-green'
30
+ healthCheckTimeout: number
31
+ ```
32
+
33
+ ## Project Configuration
34
+
35
+ ### `project.name`
36
+
37
+ - **Type**: `string`
38
+ - **Required**: Yes
39
+ - **Description**: Name of your project
40
+
41
+ ```yaml
42
+ project:
43
+ name: my-awesome-app
44
+ ```
45
+
46
+ ### `project.version`
47
+
48
+ - **Type**: `string`
49
+ - **Required**: Yes
50
+ - **Description**: Version of your project
51
+
52
+ ```yaml
53
+ project:
54
+ version: 1.0.0
55
+ ```
56
+
57
+ ## Service Configuration
58
+
59
+ Each service represents an application or service that will be deployed and exposed via Nginx.
60
+
61
+ ### `services[].name`
62
+
63
+ - **Type**: `string`
64
+ - **Required**: Yes
65
+ - **Description**: Unique name for the service. Used for Nginx configuration files and Docker containers.
66
+
67
+ ```yaml
68
+ services:
69
+ - name: api
70
+ ```
71
+
72
+ ### `services[].port`
73
+
74
+ - **Type**: `number`
75
+ - **Required**: Yes
76
+ - **Description**: Port number where the service is listening (1-65535)
77
+
78
+ ```yaml
79
+ services:
80
+ - name: api
81
+ port: 3000
82
+ ```
83
+
84
+ ### `services[].domains`
85
+
86
+ - **Type**: `string[]`
87
+ - **Required**: Yes
88
+ - **Description**: Array of domain names or subdomains that will route to this service
89
+
90
+ ```yaml
91
+ services:
92
+ - name: api
93
+ domains:
94
+ - api.example.com
95
+ - www.api.example.com
96
+ ```
97
+
98
+ ### `services[].docker` (Optional)
99
+
100
+ Docker configuration for containerized services.
101
+
102
+ #### `docker.image`
103
+
104
+ - **Type**: `string`
105
+ - **Required**: No
106
+ - **Description**: Docker image to use. If omitted, Suthep will connect to an existing container.
107
+
108
+ ```yaml
109
+ services:
110
+ - name: webapp
111
+ docker:
112
+ image: nginx:latest
113
+ ```
114
+
115
+ #### `docker.container`
116
+
117
+ - **Type**: `string`
118
+ - **Required**: Yes (if `docker` is specified)
119
+ - **Description**: Name of the Docker container
120
+
121
+ ```yaml
122
+ services:
123
+ - name: webapp
124
+ docker:
125
+ container: webapp-container
126
+ ```
127
+
128
+ #### `docker.port`
129
+
130
+ - **Type**: `number`
131
+ - **Required**: Yes (if `docker` is specified)
132
+ - **Description**: Port inside the container that the service listens on
133
+
134
+ ```yaml
135
+ services:
136
+ - name: webapp
137
+ port: 8080
138
+ docker:
139
+ port: 80 # Container's internal port
140
+ ```
141
+
142
+ **Note**: The `service.port` is the host port, and `docker.port` is the container port. Suthep will map `service.port:docker.port`.
143
+
144
+ ### `services[].healthCheck` (Optional)
145
+
146
+ Health check configuration for the service.
147
+
148
+ #### `healthCheck.path`
149
+
150
+ - **Type**: `string`
151
+ - **Required**: Yes (if `healthCheck` is specified)
152
+ - **Description**: HTTP path to the health check endpoint
153
+
154
+ ```yaml
155
+ services:
156
+ - name: api
157
+ healthCheck:
158
+ path: /health
159
+ ```
160
+
161
+ #### `healthCheck.interval`
162
+
163
+ - **Type**: `number`
164
+ - **Required**: Yes (if `healthCheck` is specified)
165
+ - **Description**: Health check interval in seconds
166
+
167
+ ```yaml
168
+ services:
169
+ - name: api
170
+ healthCheck:
171
+ interval: 30
172
+ ```
173
+
174
+ ### `services[].environment` (Optional)
175
+
176
+ - **Type**: `Record<string, string>`
177
+ - **Required**: No
178
+ - **Description**: Environment variables to pass to Docker containers
179
+
180
+ ```yaml
181
+ services:
182
+ - name: api
183
+ docker:
184
+ image: myapp/api:latest
185
+ container: api-container
186
+ port: 3000
187
+ environment:
188
+ NODE_ENV: production
189
+ DATABASE_URL: postgresql://localhost:5432/mydb
190
+ API_KEY: secret-key
191
+ ```
192
+
193
+ ## Nginx Configuration
194
+
195
+ ### `nginx.configPath`
196
+
197
+ - **Type**: `string`
198
+ - **Required**: Yes
199
+ - **Default**: `/etc/nginx/sites-available`
200
+ - **Description**: Path where Nginx configuration files will be stored
201
+
202
+ ```yaml
203
+ nginx:
204
+ configPath: /etc/nginx/sites-available
205
+ ```
206
+
207
+ ### `nginx.reloadCommand`
208
+
209
+ - **Type**: `string`
210
+ - **Required**: Yes
211
+ - **Description**: Command to test and reload Nginx configuration
212
+
213
+ ```yaml
214
+ nginx:
215
+ reloadCommand: sudo nginx -t && sudo systemctl reload nginx
216
+ ```
217
+
218
+ ## Certbot Configuration
219
+
220
+ ### `certbot.email`
221
+
222
+ - **Type**: `string`
223
+ - **Required**: Yes
224
+ - **Description**: Email address for Let's Encrypt certificate notifications
225
+
226
+ ```yaml
227
+ certbot:
228
+ email: admin@example.com
229
+ ```
230
+
231
+ ### `certbot.staging`
232
+
233
+ - **Type**: `boolean`
234
+ - **Required**: Yes
235
+ - **Description**: Use Let's Encrypt staging environment (for testing). Set to `true` during development to avoid rate limits.
236
+
237
+ ```yaml
238
+ certbot:
239
+ staging: false # Use production certificates
240
+ ```
241
+
242
+ **Important**: Set `staging: true` when testing to avoid hitting Let's Encrypt rate limits.
243
+
244
+ ## Deployment Configuration
245
+
246
+ ### `deployment.strategy`
247
+
248
+ - **Type**: `'rolling' | 'blue-green'`
249
+ - **Required**: Yes
250
+ - **Description**: Deployment strategy to use
251
+
252
+ ```yaml
253
+ deployment:
254
+ strategy: rolling
255
+ ```
256
+
257
+ **Options**:
258
+ - `rolling`: Gradually replaces old instances with new ones (default)
259
+ - `blue-green`: Maintains two identical environments and switches between them
260
+
261
+ ### `deployment.healthCheckTimeout`
262
+
263
+ - **Type**: `number`
264
+ - **Required**: Yes
265
+ - **Description**: Maximum time (in milliseconds) to wait for a service to become healthy
266
+
267
+ ```yaml
268
+ deployment:
269
+ healthCheckTimeout: 30000 # 30 seconds
270
+ ```
271
+
272
+ ## Complete Example
273
+
274
+ ```yaml
275
+ project:
276
+ name: my-awesome-app
277
+ version: 1.0.0
278
+
279
+ services:
280
+ # Simple Node.js API
281
+ - name: api
282
+ port: 3000
283
+ domains:
284
+ - api.example.com
285
+ healthCheck:
286
+ path: /health
287
+ interval: 30
288
+ environment:
289
+ NODE_ENV: production
290
+
291
+ # Docker-based web application
292
+ - name: webapp
293
+ port: 8080
294
+ docker:
295
+ image: nginx:latest
296
+ container: webapp-container
297
+ port: 80
298
+ domains:
299
+ - example.com
300
+ - www.example.com
301
+ healthCheck:
302
+ path: /
303
+ interval: 30
304
+
305
+ # Connect to existing Docker container
306
+ - name: database-proxy
307
+ port: 5432
308
+ docker:
309
+ container: postgres-container
310
+ port: 5432
311
+ domains:
312
+ - db.example.com
313
+
314
+ nginx:
315
+ configPath: /etc/nginx/sites-available
316
+ reloadCommand: sudo nginx -t && sudo systemctl reload nginx
317
+
318
+ certbot:
319
+ email: admin@example.com
320
+ staging: false
321
+
322
+ deployment:
323
+ strategy: rolling
324
+ healthCheckTimeout: 30000
325
+ ```
326
+
327
+ ## Configuration Validation
328
+
329
+ Suthep validates your configuration file when you run `suthep deploy`. Common validation errors:
330
+
331
+ - Missing required fields
332
+ - Invalid port numbers (must be 1-65535)
333
+ - Invalid email format
334
+ - Duplicate service names
335
+ - Missing Docker container name when Docker is enabled
336
+
337
+ ## Environment Variables
338
+
339
+ You can use environment variables in your configuration file by using `${VAR_NAME}` syntax (if your YAML parser supports it), or by using a templating tool before deployment.
340
+
341
+ ## Best Practices
342
+
343
+ 1. **Use staging mode during development**: Set `certbot.staging: true` to avoid rate limits
344
+ 2. **Always configure health checks**: Helps ensure services are ready before traffic is routed
345
+ 3. **Use descriptive service names**: Makes Nginx configs easier to manage
346
+ 4. **Keep configuration in version control**: Track changes to your deployment configuration
347
+ 5. **Test locally first**: Use staging certificates and test domains before production