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
package/example/README.md CHANGED
@@ -1,85 +1,314 @@
1
- # Local Docker Setup
1
+ # Suthep Configuration Examples
2
2
 
3
- This directory contains configuration files for running services locally with Docker.
3
+ This directory contains comprehensive examples showing how to configure Suthep for various deployment scenarios.
4
4
 
5
- ## Files
5
+ ## Directory Structure
6
6
 
7
- - `example.yml` - Suthep deployment configuration
8
- - `docker-compose.yml` - Docker Compose configuration for local development
7
+ ```
8
+ example/
9
+ ├── services/ # Individual service configurations
10
+ │ ├── api-no-docker.yml # Service without Docker container
11
+ │ ├── webapp-docker.yml # Service with Docker image
12
+ │ ├── dashboard-docker.yml # Service with Docker + environment variables
13
+ │ ├── database-proxy.yml # Connecting to existing Docker container
14
+ │ ├── api-path-routing.yml # API service with path-based routing
15
+ │ └── ui-path-routing.yml # UI service with path-based routing
16
+ ├── configs/ # Complete configuration files
17
+ │ ├── suthep-complete.yml # All service types combined
18
+ │ ├── suthep-no-docker.yml # Services without Docker
19
+ │ ├── suthep-docker-only.yml # All Docker services
20
+ │ └── suthep-path-routing.yml # Path-based routing example
21
+ ├── nginx/ # Nginx configuration examples
22
+ │ ├── nginx-template.conf # Single service template
23
+ │ └── nginx-multi-service.conf # Multi-service template
24
+ ├── docker/ # Docker-related examples
25
+ │ ├── docker-compose.example.yml # Docker Compose example
26
+ │ └── Dockerfile.example # Example Dockerfile
27
+ └── README.md # This file
28
+ ```
9
29
 
10
- ## Quick Start
30
+ ## Service Types
11
31
 
12
- To run the services locally with Docker Compose:
32
+ ### 1. Services Without Docker
13
33
 
14
- ```bash
15
- # Start all services
16
- docker-compose up -d
34
+ These services run directly on the host machine (managed by PM2, systemd, supervisor, etc.).
35
+
36
+ **Example:** `services/api-no-docker.yml`
37
+
38
+ ```yaml
39
+ - name: api
40
+ port: 3000
41
+ domains:
42
+ - api.example.com
43
+ healthCheck:
44
+ path: /health
45
+ interval: 30
46
+ ```
47
+
48
+ **Use Cases:**
49
+ - Node.js apps managed by PM2
50
+ - Python apps with Gunicorn/systemd
51
+ - Go binaries running as systemd services
52
+ - Any process listening on a specific port
53
+
54
+ ### 2. Services With Docker Image
17
55
 
18
- # View logs
19
- docker-compose logs -f
56
+ Suthep will pull the image and create a new container.
20
57
 
21
- # Stop all services
22
- docker-compose down
58
+ **Example:** `services/webapp-docker.yml`
23
59
 
24
- # Stop and remove volumes
25
- docker-compose down -v
60
+ ```yaml
61
+ - name: webapp
62
+ port: 8080
63
+ docker:
64
+ image: nginx:latest
65
+ container: webapp-container
66
+ port: 80
67
+ domains:
68
+ - example.com
26
69
  ```
27
70
 
28
- ## Services
71
+ **Use Cases:**
72
+ - Applications packaged as Docker images
73
+ - Third-party services from Docker Hub
74
+ - Services that need containerization
29
75
 
30
- Based on `example.yml`, this Docker Compose file includes:
76
+ ### 3. Services Connecting to Existing Containers
31
77
 
32
- 1. **webapp** (port 8080)
33
- - Image: `nginx:latest`
34
- - Container: `webapp-container`
35
- - Maps to container port 80
78
+ Connect to containers already running (e.g., from docker-compose).
36
79
 
37
- 2. **dashboard** (port 5000)
38
- - Image: `myapp/dashboard:latest` (you may need to build this)
39
- - Container: `dashboard-container`
40
- - Environment variables: `DATABASE_URL`, `REDIS_URL`
80
+ **Example:** `services/database-proxy.yml`
41
81
 
42
- 3. **postgres** (port 5432)
43
- - Image: `postgres:latest`
44
- - Container: `postgres-container`
45
- - Database: `dashboard`
46
- - Default credentials: `postgres/postgres`
82
+ ```yaml
83
+ - name: database-proxy
84
+ port: 5432
85
+ docker:
86
+ container: postgres-container
87
+ port: 5432
88
+ domains:
89
+ - db.example.com
90
+ ```
91
+
92
+ **Use Cases:**
93
+ - Containers managed by docker-compose
94
+ - Pre-existing containers
95
+ - Infrastructure services (databases, Redis, etc.)
96
+
97
+ ### 4. Path-Based Routing
98
+
99
+ Multiple services on the same domain using different paths.
100
+
101
+ **Example:** `services/api-path-routing.yml` + `services/ui-path-routing.yml`
102
+
103
+ ```yaml
104
+ # API on /api path
105
+ - name: api
106
+ port: 3001
107
+ path: /api
108
+ domains:
109
+ - muacle.com
110
+
111
+ # UI on root path
112
+ - name: ui
113
+ port: 3000
114
+ path: /
115
+ domains:
116
+ - muacle.com
117
+ ```
47
118
 
48
- 4. **redis** (port 6379)
49
- - Image: `redis:latest`
50
- - Container: `redis-container`
119
+ **Use Cases:**
120
+ - Monorepo deployments
121
+ - Microservices on single domain
122
+ - API + UI on same domain
51
123
 
52
- ## Notes
124
+ ## Complete Configuration Examples
53
125
 
54
- - The **api** service from `example.yml` is not included here as it's a Node.js service (not Docker-based)
55
- - All services are connected via a Docker network named `suthep-network`
56
- - The dashboard service depends on postgres and redis, so they will start in order
57
- - PostgreSQL data is persisted in a Docker volume
126
+ ### Complete Example
127
+ **File:** `configs/suthep-complete.yml`
58
128
 
59
- ## Building Custom Images
129
+ Combines all service types in a single configuration. Great for understanding all options.
60
130
 
61
- If you need to build the dashboard image:
131
+ ### No Docker Example
132
+ **File:** `configs/suthep-no-docker.yml`
133
+
134
+ All services run directly on the host. Perfect for traditional deployments without containerization.
135
+
136
+ ### Docker Only Example
137
+ **File:** `configs/suthep-docker-only.yml`
138
+
139
+ All services are Docker containers. Ideal for fully containerized architectures.
140
+
141
+ ### Path Routing Example
142
+ **File:** `configs/suthep-path-routing.yml`
143
+
144
+ Shows how to route multiple services on the same domain using paths.
145
+
146
+ ## Using the Examples
147
+
148
+ ### Option 1: Copy a Complete Config
62
149
 
63
150
  ```bash
64
- # Build the dashboard image
65
- docker build -t myapp/dashboard:latest ./path-to-dashboard
151
+ # Copy a complete example
152
+ cp example/configs/suthep-complete.yml suthep.yml
153
+
154
+ # Edit with your settings
155
+ nano suthep.yml
66
156
 
67
- # Or update the docker-compose.yml to build from source:
68
- # dashboard:
69
- # build: ./path-to-dashboard
70
- # ...
157
+ # Deploy
158
+ suthep deploy
71
159
  ```
72
160
 
73
- ## Accessing Services
161
+ ### Option 2: Build from Individual Services
74
162
 
75
- Once running, services are available at:
163
+ ```bash
164
+ # Create your config file
165
+ cat > suthep.yml << EOF
166
+ project:
167
+ name: my-app
168
+ version: 1.0.0
169
+
170
+ services:
171
+ EOF
172
+
173
+ # Add services from examples
174
+ cat example/services/api-no-docker.yml >> suthep.yml
175
+ cat example/services/webapp-docker.yml >> suthep.yml
176
+
177
+ # Add nginx and certbot config
178
+ cat >> suthep.yml << EOF
76
179
 
77
- - Webapp: http://localhost:8080
78
- - Dashboard: http://localhost:5000
79
- - PostgreSQL: localhost:5432
80
- - Redis: localhost:6379
180
+ nginx:
181
+ configPath: /etc/nginx/sites-available
182
+ reloadCommand: sudo nginx -t && sudo systemctl reload nginx
183
+
184
+ certbot:
185
+ email: admin@example.com
186
+ staging: false
187
+
188
+ deployment:
189
+ strategy: rolling
190
+ healthCheckTimeout: 30000
191
+ EOF
192
+
193
+ # Deploy
194
+ suthep deploy
195
+ ```
196
+
197
+ ### Option 3: Mix and Match
198
+
199
+ Combine individual service examples to create your custom configuration:
200
+
201
+ ```bash
202
+ # Start with project header
203
+ cat > suthep.yml << EOF
204
+ project:
205
+ name: my-custom-app
206
+ version: 1.0.0
207
+
208
+ services:
209
+ EOF
210
+
211
+ # Add specific services you need
212
+ cat example/services/api-no-docker.yml >> suthep.yml
213
+ cat example/services/database-proxy.yml >> suthep.yml
214
+
215
+ # Add standard config
216
+ cat >> suthep.yml << EOF
217
+
218
+ nginx:
219
+ configPath: /etc/nginx/sites-available
220
+ reloadCommand: sudo nginx -t && sudo systemctl reload nginx
221
+
222
+ certbot:
223
+ email: your-email@example.com
224
+ staging: false
225
+
226
+ deployment:
227
+ strategy: rolling
228
+ healthCheckTimeout: 30000
229
+ EOF
230
+ ```
231
+
232
+ ## Additional Files
233
+
234
+ ### Nginx Templates
235
+
236
+ The `nginx/` directory contains example configurations that Suthep generates automatically. You typically don't need to edit these manually, but they're useful for understanding how Suthep configures Nginx.
237
+
238
+ ### Docker Examples
239
+
240
+ The `docker/` directory contains:
241
+ - `docker-compose.example.yml`: Shows how to run containers that Suthep can connect to
242
+ - `Dockerfile.example`: Example Dockerfile for building your application images
243
+
244
+ ## Configuration Reference
245
+
246
+ ### Service Configuration
247
+
248
+ | Property | Required | Description |
249
+ |----------|----------|-------------|
250
+ | `name` | ✅ | Unique identifier for the service |
251
+ | `port` | ✅ | Port number the service runs on (host port) |
252
+ | `domains` | ✅ | Array of domain names or subdomains |
253
+ | `docker` | ❌ | Docker configuration (see below) |
254
+ | `path` | ❌ | Path prefix (e.g., `/api`, `/`). Defaults to `/` |
255
+ | `healthCheck` | ❌ | Health check configuration |
256
+ | `environment` | ❌ | Environment variables (key-value pairs) |
257
+
258
+ ### Docker Configuration
259
+
260
+ When using Docker:
261
+
262
+ ```yaml
263
+ docker:
264
+ image: nginx:latest # Image to pull (required if creating new container)
265
+ container: my-container # Container name (required)
266
+ port: 80 # Internal container port (required)
267
+ ```
268
+
269
+ - **With image**: Suthep creates a new container from the image
270
+ - **Without image**: Suthep connects to an existing container
271
+
272
+ ### Health Check Configuration
273
+
274
+ ```yaml
275
+ healthCheck:
276
+ path: /health # HTTP endpoint path
277
+ interval: 30 # Check interval in seconds
278
+ ```
279
+
280
+ ### Deployment Configuration
281
+
282
+ ```yaml
283
+ deployment:
284
+ strategy: rolling # Options: rolling, blue-green
285
+ healthCheckTimeout: 30000 # Timeout in milliseconds
286
+ ```
287
+
288
+ ## Quick Start
81
289
 
290
+ 1. **Choose an example** from `configs/` or build from `services/`
291
+ 2. **Copy to `suthep.yml`** in your project root
292
+ 3. **Edit the configuration** with your actual domains and settings
293
+ 4. **Run setup** (first time only):
294
+ ```bash
295
+ suthep setup
296
+ ```
297
+ 5. **Deploy**:
298
+ ```bash
299
+ suthep deploy
300
+ ```
82
301
 
302
+ ## Tips
83
303
 
304
+ - **Testing**: Set `certbot.staging: true` when testing to avoid rate limits
305
+ - **Path Routing**: Order matters - most specific paths should be defined first
306
+ - **Existing Containers**: Ensure containers are running and accessible before deployment
307
+ - **Port Conflicts**: Each service must use a unique port
308
+ - **Container Names**: Each Docker container must have a unique name
84
309
 
310
+ ## Need Help?
85
311
 
312
+ - Check the main [README.md](../README.md) for command reference
313
+ - Review the [suthep.example.yml](../suthep.example.yml) in the project root
314
+ - See individual service examples in `services/` for specific use cases
@@ -0,0 +1,103 @@
1
+ # Complete Example Configuration
2
+ # This combines all service types for a comprehensive deployment
3
+
4
+ project:
5
+ name: my-app
6
+ version: 1.0.0
7
+
8
+ services:
9
+ # Service 1: Simple API without Docker (runs directly on host)
10
+ - name: api
11
+ port: 3000
12
+ domains:
13
+ - api.example.com
14
+ - www.api.example.com
15
+ healthCheck:
16
+ path: /health
17
+ interval: 30
18
+ environment:
19
+ NODE_ENV: production
20
+ PORT: 3000
21
+
22
+ # Service 2: Web application with Docker image
23
+ - name: webapp
24
+ port: 8080
25
+ docker:
26
+ image: nginx:latest
27
+ container: webapp-container
28
+ port: 80
29
+ domains:
30
+ - example.com
31
+ - www.example.com
32
+ healthCheck:
33
+ path: /
34
+ interval: 30
35
+
36
+ # Service 3: Dashboard with Docker and environment variables
37
+ - name: dashboard
38
+ port: 5000
39
+ docker:
40
+ image: myapp/dashboard:latest
41
+ container: dashboard-container
42
+ port: 5000
43
+ domains:
44
+ - dashboard.example.com
45
+ - admin.example.com
46
+ healthCheck:
47
+ path: /api/health
48
+ interval: 60
49
+ environment:
50
+ DATABASE_URL: postgresql://localhost:5432/dashboard
51
+ REDIS_URL: redis://localhost:6379
52
+
53
+ # Service 4: Connect to existing Docker container
54
+ - name: database-proxy
55
+ port: 5432
56
+ docker:
57
+ container: postgres-container
58
+ port: 5432
59
+ domains:
60
+ - db.example.com
61
+
62
+ # Service 5: Path-based routing - API on /api path
63
+ - name: api-v2
64
+ port: 3001
65
+ path: /api
66
+ domains:
67
+ - muacle.com
68
+ docker:
69
+ image: myapp/api:latest
70
+ container: api-v2-container
71
+ port: 3001
72
+ healthCheck:
73
+ path: /health
74
+ interval: 30
75
+
76
+ # Service 6: Path-based routing - UI on root path
77
+ - name: ui
78
+ port: 3000
79
+ path: /
80
+ domains:
81
+ - muacle.com
82
+ docker:
83
+ image: myapp/ui:latest
84
+ container: ui-container
85
+ port: 3000
86
+ healthCheck:
87
+ path: /
88
+ interval: 30
89
+
90
+ # Nginx Configuration
91
+ nginx:
92
+ configPath: /etc/nginx/sites-available
93
+ reloadCommand: sudo nginx -t && sudo systemctl reload nginx
94
+
95
+ # Certbot Configuration (SSL/TLS certificates)
96
+ certbot:
97
+ email: admin@example.com
98
+ staging: false # Set to true for testing
99
+
100
+ # Deployment Strategy
101
+ deployment:
102
+ strategy: rolling # Options: rolling, blue-green
103
+ healthCheckTimeout: 30000 # milliseconds
@@ -0,0 +1,71 @@
1
+ # Example: Configuration with Docker Only
2
+ # All services are deployed as Docker containers
3
+
4
+ project:
5
+ name: docker-app
6
+ version: 1.0.0
7
+
8
+ services:
9
+ # Frontend application
10
+ - name: frontend
11
+ port: 3000
12
+ docker:
13
+ image: myapp/frontend:latest
14
+ container: frontend-container
15
+ port: 3000
16
+ domains:
17
+ - example.com
18
+ - www.example.com
19
+ healthCheck:
20
+ path: /
21
+ interval: 30
22
+
23
+ # Backend API
24
+ - name: backend
25
+ port: 4000
26
+ docker:
27
+ image: myapp/backend:latest
28
+ container: backend-container
29
+ port: 4000
30
+ domains:
31
+ - api.example.com
32
+ healthCheck:
33
+ path: /api/health
34
+ interval: 30
35
+ environment:
36
+ NODE_ENV: production
37
+ DATABASE_URL: postgresql://db:5432/mydb
38
+
39
+ # Worker service
40
+ - name: worker
41
+ port: 5000
42
+ docker:
43
+ image: myapp/worker:latest
44
+ container: worker-container
45
+ port: 5000
46
+ domains:
47
+ - worker.example.com
48
+ healthCheck:
49
+ path: /health
50
+ interval: 60
51
+
52
+ # Redis proxy (connecting to existing container)
53
+ - name: redis-proxy
54
+ port: 6379
55
+ docker:
56
+ container: redis-container
57
+ port: 6379
58
+ domains:
59
+ - redis.example.com
60
+
61
+ nginx:
62
+ configPath: /etc/nginx/sites-available
63
+ reloadCommand: sudo nginx -t && sudo systemctl reload nginx
64
+
65
+ certbot:
66
+ email: admin@example.com
67
+ staging: false
68
+
69
+ deployment:
70
+ strategy: rolling
71
+ healthCheckTimeout: 30000
@@ -0,0 +1,51 @@
1
+ # Example: Configuration without Docker
2
+ # All services run directly on the host machine
3
+ # Useful for services managed by PM2, systemd, supervisor, etc.
4
+
5
+ project:
6
+ name: my-app
7
+ version: 1.0.0
8
+
9
+ services:
10
+ # Node.js API service (e.g., running with PM2)
11
+ - name: api
12
+ port: 3000
13
+ domains:
14
+ - api.example.com
15
+ healthCheck:
16
+ path: /health
17
+ interval: 30
18
+ environment:
19
+ NODE_ENV: production
20
+ PORT: 3000
21
+
22
+ # Python web service (e.g., running with Gunicorn)
23
+ - name: web
24
+ port: 8000
25
+ domains:
26
+ - example.com
27
+ - www.example.com
28
+ healthCheck:
29
+ path: /health
30
+ interval: 30
31
+
32
+ # Go microservice
33
+ - name: auth
34
+ port: 4000
35
+ domains:
36
+ - auth.example.com
37
+ healthCheck:
38
+ path: /status
39
+ interval: 60
40
+
41
+ nginx:
42
+ configPath: /etc/nginx/sites-available
43
+ reloadCommand: sudo nginx -t && sudo systemctl reload nginx
44
+
45
+ certbot:
46
+ email: admin@example.com
47
+ staging: false
48
+
49
+ deployment:
50
+ strategy: rolling
51
+ healthCheckTimeout: 30000
@@ -1,5 +1,9 @@
1
+ # Example: Path-based Routing Configuration
2
+ # Multiple services on the same domain using different paths
3
+ # This is useful for monorepo deployments or microservices
4
+
1
5
  project:
2
- name: muacle-app
6
+ name: path-routing-app
3
7
  version: 1.0.0
4
8
 
5
9
  services:
@@ -16,8 +20,6 @@ services:
16
20
  healthCheck:
17
21
  path: /health
18
22
  interval: 30
19
- environment:
20
- NODE_ENV: production
21
23
 
22
24
  # UI service on root path
23
25
  - name: ui
@@ -33,15 +35,28 @@ services:
33
35
  path: /
34
36
  interval: 30
35
37
 
38
+ # Admin service on /admin path
39
+ - name: admin
40
+ port: 3002
41
+ path: /admin
42
+ domains:
43
+ - muacle.com
44
+ docker:
45
+ image: myapp/admin:latest
46
+ container: admin-container
47
+ port: 3002
48
+ healthCheck:
49
+ path: /health
50
+ interval: 30
51
+
36
52
  nginx:
37
53
  configPath: /etc/nginx/sites-available
38
54
  reloadCommand: sudo nginx -t && sudo systemctl reload nginx
39
55
 
40
56
  certbot:
41
- email: admin@muacle.com
57
+ email: admin@example.com
42
58
  staging: false
43
59
 
44
60
  deployment:
45
61
  strategy: rolling
46
62
  healthCheckTimeout: 30000
47
-