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.
- package/README.md +167 -69
- package/dist/commands/down.js +179 -0
- package/dist/commands/down.js.map +1 -0
- package/dist/commands/redeploy.js +59 -0
- package/dist/commands/redeploy.js.map +1 -0
- package/dist/commands/up.js +213 -0
- package/dist/commands/up.js.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/deployment.js +10 -1
- package/dist/utils/deployment.js.map +1 -1
- package/dist/utils/docker.js +35 -0
- package/dist/utils/docker.js.map +1 -1
- package/dist/utils/nginx.js +10 -0
- package/dist/utils/nginx.js.map +1 -1
- package/docs/README.md +25 -82
- package/docs/english/01-introduction.md +84 -0
- package/docs/english/02-installation.md +200 -0
- package/docs/english/03-quick-start.md +256 -0
- package/docs/english/04-configuration.md +358 -0
- package/docs/english/05-commands.md +363 -0
- package/docs/english/06-examples.md +456 -0
- package/docs/english/07-troubleshooting.md +417 -0
- package/docs/english/08-advanced.md +411 -0
- package/docs/english/README.md +48 -0
- package/docs/thai/01-introduction.md +84 -0
- package/docs/thai/02-installation.md +200 -0
- package/docs/thai/03-quick-start.md +256 -0
- package/docs/thai/04-configuration.md +358 -0
- package/docs/thai/05-commands.md +363 -0
- package/docs/thai/06-examples.md +456 -0
- package/docs/thai/07-troubleshooting.md +417 -0
- package/docs/thai/08-advanced.md +411 -0
- package/docs/thai/README.md +48 -0
- package/example/README.md +282 -53
- package/example/suthep-complete.yml +103 -0
- package/example/suthep-docker-only.yml +71 -0
- package/example/suthep-no-docker.yml +51 -0
- package/example/{muacle.yml → suthep-path-routing.yml} +20 -5
- package/example/suthep.example.yml +89 -0
- package/package.json +1 -1
- package/src/commands/down.ts +240 -0
- package/src/commands/redeploy.ts +78 -0
- package/src/commands/up.ts +271 -0
- package/src/index.ts +53 -0
- package/suthep-0.1.0-beta.1.tgz +0 -0
- package/suthep.example.yml +5 -0
- package/suthep.yml +39 -0
- package/docs/TRANSLATIONS.md +0 -211
- package/docs/en/README.md +0 -76
- package/docs/en/api-reference.md +0 -545
- package/docs/en/architecture.md +0 -369
- package/docs/en/commands.md +0 -273
- package/docs/en/configuration.md +0 -347
- package/docs/en/developer-guide.md +0 -588
- package/docs/en/docker-ports-config.md +0 -333
- package/docs/en/examples.md +0 -537
- package/docs/en/getting-started.md +0 -202
- package/docs/en/port-binding.md +0 -268
- package/docs/en/troubleshooting.md +0 -441
- package/docs/th/README.md +0 -64
- package/docs/th/commands.md +0 -202
- package/docs/th/configuration.md +0 -325
- package/docs/th/getting-started.md +0 -203
- package/example/docker-compose.yml +0 -76
- package/example/docker-ports-example.yml +0 -81
- package/example/port-binding-example.yml +0 -45
- package/example/suthep.yml +0 -46
- package/example/suthep=1.yml +0 -46
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
# Docker Port Configuration in suthep.yml
|
|
2
|
-
|
|
3
|
-
This guide explains how to configure and export Docker ports in your `suthep.yml` configuration file.
|
|
4
|
-
|
|
5
|
-
## Port Configuration Structure
|
|
6
|
-
|
|
7
|
-
In `suthep.yml`, Docker ports are configured using two fields:
|
|
8
|
-
|
|
9
|
-
```yaml
|
|
10
|
-
services:
|
|
11
|
-
- name: my-service
|
|
12
|
-
port: 3002 # Host port (exposed on your machine)
|
|
13
|
-
docker:
|
|
14
|
-
image: myapp/service:latest
|
|
15
|
-
container: my-container
|
|
16
|
-
port: 3000 # Container port (inside Docker)
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Port Fields Explained
|
|
20
|
-
|
|
21
|
-
| Field | Location | Description | Example |
|
|
22
|
-
|-------|----------|-------------|---------|
|
|
23
|
-
| `port` | `service.port` | **Host port** - Port accessible on your host machine | `3002` |
|
|
24
|
-
| `port` | `service.docker.port` | **Container port** - Port your app listens on inside the container | `3000` |
|
|
25
|
-
|
|
26
|
-
## How Port Mapping Works
|
|
27
|
-
|
|
28
|
-
Suthep automatically creates a Docker port mapping in the format:
|
|
29
|
-
```
|
|
30
|
-
hostPort:containerPort
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Example Configuration:**
|
|
34
|
-
```yaml
|
|
35
|
-
- name: api
|
|
36
|
-
port: 3002 # Host port
|
|
37
|
-
docker:
|
|
38
|
-
port: 3000 # Container port
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
**Docker Command Generated:**
|
|
42
|
-
```bash
|
|
43
|
-
docker run -p 3002:3000 --name api-container myapp/api:latest
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
**Result:**
|
|
47
|
-
- External access: `localhost:3002` → forwards to container port `3000`
|
|
48
|
-
- Inside container: Your app listens on port `3000`
|
|
49
|
-
- Nginx connects to: `localhost:3002`
|
|
50
|
-
|
|
51
|
-
## Configuration Examples
|
|
52
|
-
|
|
53
|
-
### Example 1: Same Port on Host and Container
|
|
54
|
-
|
|
55
|
-
When your app uses the same port inside and outside the container:
|
|
56
|
-
|
|
57
|
-
```yaml
|
|
58
|
-
services:
|
|
59
|
-
- name: api
|
|
60
|
-
port: 3000 # Host: 3000
|
|
61
|
-
docker:
|
|
62
|
-
image: myapp/api:latest
|
|
63
|
-
container: api-container
|
|
64
|
-
port: 3000 # Container: 3000
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
**Port Mapping:** `3000:3000`
|
|
68
|
-
|
|
69
|
-
### Example 2: Different Host and Container Ports
|
|
70
|
-
|
|
71
|
-
When you want to expose a different host port:
|
|
72
|
-
|
|
73
|
-
```yaml
|
|
74
|
-
services:
|
|
75
|
-
- name: api
|
|
76
|
-
port: 3002 # Host: 3002 (external)
|
|
77
|
-
docker:
|
|
78
|
-
image: myapp/api:latest
|
|
79
|
-
container: api-container
|
|
80
|
-
port: 3000 # Container: 3000 (internal)
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
**Port Mapping:** `3002:3000`
|
|
84
|
-
- Access from host: `localhost:3002`
|
|
85
|
-
- App inside container: listens on `3000`
|
|
86
|
-
|
|
87
|
-
### Example 3: Nginx Container (Port 80 → 8080)
|
|
88
|
-
|
|
89
|
-
Common scenario: Nginx listens on port 80 inside container, but you expose it on 8080:
|
|
90
|
-
|
|
91
|
-
```yaml
|
|
92
|
-
services:
|
|
93
|
-
- name: web
|
|
94
|
-
port: 8080 # Host: 8080
|
|
95
|
-
docker:
|
|
96
|
-
image: nginx:alpine
|
|
97
|
-
container: web-container
|
|
98
|
-
port: 80 # Container: 80 (Nginx default)
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
**Port Mapping:** `8080:80`
|
|
102
|
-
- Access from host: `localhost:8080`
|
|
103
|
-
- Nginx inside container: listens on `80`
|
|
104
|
-
|
|
105
|
-
### Example 4: Multiple Services with Different Ports
|
|
106
|
-
|
|
107
|
-
```yaml
|
|
108
|
-
services:
|
|
109
|
-
# API service
|
|
110
|
-
- name: api
|
|
111
|
-
port: 3001 # Host: 3001
|
|
112
|
-
docker:
|
|
113
|
-
image: myapp/api:latest
|
|
114
|
-
container: api-container
|
|
115
|
-
port: 3000 # Container: 3000
|
|
116
|
-
|
|
117
|
-
# Web service
|
|
118
|
-
- name: web
|
|
119
|
-
port: 8080 # Host: 8080
|
|
120
|
-
docker:
|
|
121
|
-
image: nginx:alpine
|
|
122
|
-
container: web-container
|
|
123
|
-
port: 80 # Container: 80
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
**Port Mappings:**
|
|
127
|
-
- API: `3001:3000`
|
|
128
|
-
- Web: `8080:80`
|
|
129
|
-
|
|
130
|
-
## Complete Configuration Example
|
|
131
|
-
|
|
132
|
-
```yaml
|
|
133
|
-
project:
|
|
134
|
-
name: my-app
|
|
135
|
-
version: 1.0.0
|
|
136
|
-
|
|
137
|
-
services:
|
|
138
|
-
# Service with same host/container port
|
|
139
|
-
- name: api
|
|
140
|
-
port: 3000 # Host port
|
|
141
|
-
domains:
|
|
142
|
-
- api.example.com
|
|
143
|
-
docker:
|
|
144
|
-
image: myapp/api:latest
|
|
145
|
-
container: api-container
|
|
146
|
-
port: 3000 # Container port
|
|
147
|
-
healthCheck:
|
|
148
|
-
path: /health
|
|
149
|
-
interval: 30
|
|
150
|
-
|
|
151
|
-
# Service with different host/container port
|
|
152
|
-
- name: web
|
|
153
|
-
port: 8080 # Host port (external)
|
|
154
|
-
domains:
|
|
155
|
-
- example.com
|
|
156
|
-
docker:
|
|
157
|
-
image: nginx:alpine
|
|
158
|
-
container: web-container
|
|
159
|
-
port: 80 # Container port (internal)
|
|
160
|
-
healthCheck:
|
|
161
|
-
path: /
|
|
162
|
-
interval: 30
|
|
163
|
-
|
|
164
|
-
nginx:
|
|
165
|
-
configPath: /etc/nginx/sites-available
|
|
166
|
-
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
167
|
-
|
|
168
|
-
certbot:
|
|
169
|
-
email: admin@example.com
|
|
170
|
-
staging: false
|
|
171
|
-
|
|
172
|
-
deployment:
|
|
173
|
-
strategy: rolling
|
|
174
|
-
healthCheckTimeout: 30000
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
## Port Export/Exposure
|
|
178
|
-
|
|
179
|
-
### How Ports Are Exposed
|
|
180
|
-
|
|
181
|
-
1. **Docker Port Mapping**: Suthep automatically creates the port mapping when the container is created
|
|
182
|
-
2. **Nginx Configuration**: Nginx is configured to connect to the **host port**
|
|
183
|
-
3. **Access**: Services are accessible via:
|
|
184
|
-
- Direct: `localhost:hostPort`
|
|
185
|
-
- Via Nginx: `https://your-domain.com`
|
|
186
|
-
|
|
187
|
-
### Port Visibility
|
|
188
|
-
|
|
189
|
-
- **Host Port** (`service.port`):
|
|
190
|
-
- Exposed on your host machine
|
|
191
|
-
- Accessible from outside the container
|
|
192
|
-
- Used by Nginx to connect to your service
|
|
193
|
-
- Must be unique across all services
|
|
194
|
-
|
|
195
|
-
- **Container Port** (`docker.port`):
|
|
196
|
-
- Internal to the Docker container
|
|
197
|
-
- What your application listens on inside the container
|
|
198
|
-
- Can be the same or different from host port
|
|
199
|
-
|
|
200
|
-
## Important Notes
|
|
201
|
-
|
|
202
|
-
### Port Conflicts
|
|
203
|
-
|
|
204
|
-
Suthep automatically detects port conflicts:
|
|
205
|
-
|
|
206
|
-
```yaml
|
|
207
|
-
# ❌ This will fail - same host port used twice
|
|
208
|
-
services:
|
|
209
|
-
- name: api
|
|
210
|
-
port: 3000
|
|
211
|
-
- name: web
|
|
212
|
-
port: 3000 # Error: Port conflict!
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
**Error Message:**
|
|
216
|
-
```
|
|
217
|
-
Port conflict: Service "web" uses port 3000 which is already used by: api.
|
|
218
|
-
Each service must use a unique port.
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
### Port Validation
|
|
222
|
-
|
|
223
|
-
- Host ports must be unique across all services
|
|
224
|
-
- Ports must be between 1 and 65535
|
|
225
|
-
- Container ports can be the same (they're isolated inside containers)
|
|
226
|
-
|
|
227
|
-
### Changing Ports
|
|
228
|
-
|
|
229
|
-
If you change the port configuration:
|
|
230
|
-
|
|
231
|
-
1. **Same container name**: Suthep will detect the change and recreate the container
|
|
232
|
-
2. **Different container name**: A new container will be created
|
|
233
|
-
|
|
234
|
-
**Example: Changing port from 3000 to 3002**
|
|
235
|
-
|
|
236
|
-
```yaml
|
|
237
|
-
# Old config
|
|
238
|
-
- name: api
|
|
239
|
-
port: 3000
|
|
240
|
-
docker:
|
|
241
|
-
port: 3000
|
|
242
|
-
|
|
243
|
-
# New config
|
|
244
|
-
- name: api
|
|
245
|
-
port: 3002 # Changed
|
|
246
|
-
docker:
|
|
247
|
-
port: 3000
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
When you deploy, Suthep will:
|
|
251
|
-
1. Detect the port change
|
|
252
|
-
2. Stop and remove the old container
|
|
253
|
-
3. Create a new container with the new port mapping `3002:3000`
|
|
254
|
-
|
|
255
|
-
## Troubleshooting
|
|
256
|
-
|
|
257
|
-
### Port Already in Use
|
|
258
|
-
|
|
259
|
-
**Error:** `Port 3000 is already in use`
|
|
260
|
-
|
|
261
|
-
**Solutions:**
|
|
262
|
-
1. Check what's using the port:
|
|
263
|
-
```bash
|
|
264
|
-
sudo lsof -i :3000
|
|
265
|
-
# or
|
|
266
|
-
sudo netstat -tulpn | grep 3000
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
2. Use a different port in your configuration
|
|
270
|
-
3. Stop the conflicting service/container
|
|
271
|
-
|
|
272
|
-
### Container Port Mismatch
|
|
273
|
-
|
|
274
|
-
**Problem:** Service not accessible
|
|
275
|
-
|
|
276
|
-
**Check:**
|
|
277
|
-
1. Verify your app listens on the correct port inside the container
|
|
278
|
-
2. Ensure `docker.port` matches your app's listening port
|
|
279
|
-
3. Check container logs:
|
|
280
|
-
```bash
|
|
281
|
-
docker logs container-name
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
### Port Not Accessible
|
|
285
|
-
|
|
286
|
-
**Problem:** Can't access service on host port
|
|
287
|
-
|
|
288
|
-
**Check:**
|
|
289
|
-
1. Verify container is running:
|
|
290
|
-
```bash
|
|
291
|
-
docker ps
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
2. Check port mapping:
|
|
295
|
-
```bash
|
|
296
|
-
docker port container-name
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
3. Test connection:
|
|
300
|
-
```bash
|
|
301
|
-
curl http://localhost:PORT
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
## Best Practices
|
|
305
|
-
|
|
306
|
-
1. **Use descriptive port numbers**:
|
|
307
|
-
- Development: 3000-3999
|
|
308
|
-
- Production: 8000-8999
|
|
309
|
-
|
|
310
|
-
2. **Document port usage**: Keep track of which ports are used
|
|
311
|
-
|
|
312
|
-
3. **Match container ports**: Set `docker.port` to what your app actually listens on
|
|
313
|
-
|
|
314
|
-
4. **Use unique host ports**: Each service must have a unique host port
|
|
315
|
-
|
|
316
|
-
5. **Test port mappings**: Verify ports work before deploying to production
|
|
317
|
-
|
|
318
|
-
## Quick Reference
|
|
319
|
-
|
|
320
|
-
```yaml
|
|
321
|
-
# Basic structure
|
|
322
|
-
services:
|
|
323
|
-
- name: service-name
|
|
324
|
-
port: HOST_PORT # Port on your machine
|
|
325
|
-
docker:
|
|
326
|
-
image: image:tag
|
|
327
|
-
container: container-name
|
|
328
|
-
port: CONTAINER_PORT # Port inside container
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
**Port Mapping Formula:** `HOST_PORT:CONTAINER_PORT`
|
|
332
|
-
|
|
333
|
-
**Nginx Connection:** `localhost:HOST_PORT`
|