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.
- package/.editorconfig +17 -0
- package/.prettierignore +6 -0
- package/.prettierrc +7 -0
- package/.vscode/settings.json +19 -0
- package/LICENSE +21 -0
- package/README.md +217 -0
- package/dist/commands/deploy.js +318 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/init.js +188 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/setup.js +90 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/certbot.js +64 -0
- package/dist/utils/certbot.js.map +1 -0
- package/dist/utils/config-loader.js +95 -0
- package/dist/utils/config-loader.js.map +1 -0
- package/dist/utils/deployment.js +76 -0
- package/dist/utils/deployment.js.map +1 -0
- package/dist/utils/docker.js +393 -0
- package/dist/utils/docker.js.map +1 -0
- package/dist/utils/nginx.js +303 -0
- package/dist/utils/nginx.js.map +1 -0
- package/docs/README.md +95 -0
- package/docs/TRANSLATIONS.md +211 -0
- package/docs/en/README.md +76 -0
- package/docs/en/api-reference.md +545 -0
- package/docs/en/architecture.md +369 -0
- package/docs/en/commands.md +273 -0
- package/docs/en/configuration.md +347 -0
- package/docs/en/developer-guide.md +588 -0
- package/docs/en/docker-ports-config.md +333 -0
- package/docs/en/examples.md +537 -0
- package/docs/en/getting-started.md +202 -0
- package/docs/en/port-binding.md +268 -0
- package/docs/en/troubleshooting.md +441 -0
- package/docs/th/README.md +64 -0
- package/docs/th/commands.md +202 -0
- package/docs/th/configuration.md +325 -0
- package/docs/th/getting-started.md +203 -0
- package/example/README.md +85 -0
- package/example/docker-compose.yml +76 -0
- package/example/docker-ports-example.yml +81 -0
- package/example/muacle.yml +47 -0
- package/example/port-binding-example.yml +45 -0
- package/example/suthep.yml +46 -0
- package/example/suthep=1.yml +46 -0
- package/package.json +45 -0
- package/src/commands/deploy.ts +405 -0
- package/src/commands/init.ts +214 -0
- package/src/commands/setup.ts +112 -0
- package/src/index.ts +42 -0
- package/src/types/config.ts +52 -0
- package/src/utils/certbot.ts +144 -0
- package/src/utils/config-loader.ts +121 -0
- package/src/utils/deployment.ts +157 -0
- package/src/utils/docker.ts +755 -0
- package/src/utils/nginx.ts +326 -0
- package/suthep-0.1.1.tgz +0 -0
- package/suthep.example.yml +98 -0
- package/test +0 -0
- package/todo.md +6 -0
- package/tsconfig.json +26 -0
- package/vite.config.ts +46 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# เริ่มต้นใช้งาน Suthep
|
|
2
|
+
|
|
3
|
+
คู่มือนี้จะแนะนำคุณในการติดตั้ง Suthep และ deploy service แรกของคุณ
|
|
4
|
+
|
|
5
|
+
## การติดตั้ง
|
|
6
|
+
|
|
7
|
+
### ความต้องการเบื้องต้น
|
|
8
|
+
|
|
9
|
+
ก่อนติดตั้ง Suthep ตรวจสอบว่าคุณมี:
|
|
10
|
+
|
|
11
|
+
- **Node.js 16+** - [ดาวน์โหลด Node.js](https://nodejs.org/)
|
|
12
|
+
- **สิทธิ์ sudo** - จำเป็นสำหรับการทำงานของ Nginx และ Certbot
|
|
13
|
+
- **Docker** (ไม่บังคับ) - จำเป็นเฉพาะเมื่อ deploy Docker containers
|
|
14
|
+
|
|
15
|
+
### ติดตั้ง Suthep
|
|
16
|
+
|
|
17
|
+
1. Clone หรือดาวน์โหลด repository ของ Suthep:
|
|
18
|
+
```bash
|
|
19
|
+
git clone <repository-url>
|
|
20
|
+
cd suthep
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
2. ติดตั้ง dependencies:
|
|
24
|
+
```bash
|
|
25
|
+
npm install
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
3. Link CLI tool แบบ global:
|
|
29
|
+
```bash
|
|
30
|
+
npm link
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
สิ่งนี้ทำให้คำสั่ง `suthep` ใช้งานได้ทั่วทั้งระบบของคุณ
|
|
34
|
+
|
|
35
|
+
4. ตรวจสอบการติดตั้ง:
|
|
36
|
+
```bash
|
|
37
|
+
suthep --version
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## คู่มือเริ่มต้นใช้งานอย่างรวดเร็ว
|
|
41
|
+
|
|
42
|
+
### ขั้นตอนที่ 1: เริ่มต้นการตั้งค่า
|
|
43
|
+
|
|
44
|
+
สร้างไฟล์ configuration สำหรับโปรเจกต์ของคุณ:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
suthep init
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
คำสั่งแบบ interactive นี้จะ:
|
|
51
|
+
- ถามชื่อโปรเจกต์และเวอร์ชัน
|
|
52
|
+
- แนะนำการตั้งค่า services
|
|
53
|
+
- ตั้งค่า domain names
|
|
54
|
+
- ตั้งค่า Docker (ถ้าจำเป็น)
|
|
55
|
+
- ตั้งค่า health checks
|
|
56
|
+
- ตั้งค่าอีเมล Certbot
|
|
57
|
+
|
|
58
|
+
หรือคุณสามารถคัดลอกไฟล์ configuration ตัวอย่าง:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
cp suthep.example.yml suthep.yml
|
|
62
|
+
# แก้ไข suthep.yml ด้วยการตั้งค่าของคุณ
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### ขั้นตอนที่ 2: ติดตั้ง Prerequisites
|
|
66
|
+
|
|
67
|
+
ติดตั้งและตั้งค่า Nginx และ Certbot:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
suthep setup
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
คำสั่งนี้จะ:
|
|
74
|
+
- ติดตั้ง Nginx (ถ้ายังไม่ได้ติดตั้ง)
|
|
75
|
+
- ติดตั้ง Certbot (ถ้ายังไม่ได้ติดตั้ง)
|
|
76
|
+
- เริ่มและเปิดใช้งาน Nginx service
|
|
77
|
+
|
|
78
|
+
คุณยังสามารถติดตั้งแยกกันได้:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
suthep setup --nginx-only # ติดตั้งเฉพาะ Nginx
|
|
82
|
+
suthep setup --certbot-only # ติดตั้งเฉพาะ Certbot
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### ขั้นตอนที่ 3: Deploy Services ของคุณ
|
|
86
|
+
|
|
87
|
+
Deploy โปรเจกต์ของคุณ:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
suthep deploy
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
สิ่งนี้จะ:
|
|
94
|
+
1. โหลด configuration จาก `suthep.yml`
|
|
95
|
+
2. เริ่ม Docker containers (ถ้าตั้งค่าไว้)
|
|
96
|
+
3. Deploy แต่ละ service
|
|
97
|
+
4. สร้างและเปิดใช้งาน Nginx configurations
|
|
98
|
+
5. ขอใบรับรอง SSL จาก Let's Encrypt
|
|
99
|
+
6. Reload Nginx
|
|
100
|
+
7. ทำ health checks
|
|
101
|
+
|
|
102
|
+
## การ Deploy ครั้งแรกของคุณ
|
|
103
|
+
|
|
104
|
+
มาลอง deploy Node.js API service ง่ายๆ:
|
|
105
|
+
|
|
106
|
+
### 1. สร้าง Service ง่ายๆ
|
|
107
|
+
|
|
108
|
+
สร้าง Node.js server พื้นฐาน:
|
|
109
|
+
|
|
110
|
+
```javascript
|
|
111
|
+
// server.js
|
|
112
|
+
const http = require('http');
|
|
113
|
+
|
|
114
|
+
const server = http.createServer((req, res) => {
|
|
115
|
+
if (req.url === '/health') {
|
|
116
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
117
|
+
res.end(JSON.stringify({ status: 'ok' }));
|
|
118
|
+
} else {
|
|
119
|
+
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
120
|
+
res.end('Hello from Suthep!');
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
server.listen(3000, () => {
|
|
125
|
+
console.log('Server running on port 3000');
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 2. สร้าง Configuration
|
|
130
|
+
|
|
131
|
+
สร้าง `suthep.yml`:
|
|
132
|
+
|
|
133
|
+
```yaml
|
|
134
|
+
project:
|
|
135
|
+
name: my-first-app
|
|
136
|
+
version: 1.0.0
|
|
137
|
+
|
|
138
|
+
services:
|
|
139
|
+
- name: api
|
|
140
|
+
port: 3000
|
|
141
|
+
domains:
|
|
142
|
+
- api.yourdomain.com
|
|
143
|
+
healthCheck:
|
|
144
|
+
path: /health
|
|
145
|
+
interval: 30
|
|
146
|
+
|
|
147
|
+
nginx:
|
|
148
|
+
configPath: /etc/nginx/sites-available
|
|
149
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
150
|
+
|
|
151
|
+
certbot:
|
|
152
|
+
email: your-email@example.com
|
|
153
|
+
staging: false
|
|
154
|
+
|
|
155
|
+
deployment:
|
|
156
|
+
strategy: rolling
|
|
157
|
+
healthCheckTimeout: 30000
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### 3. เริ่ม Service ของคุณ
|
|
161
|
+
|
|
162
|
+
รัน Node.js server ของคุณ:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
node server.js
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 4. Setup และ Deploy
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Setup Nginx และ Certbot
|
|
172
|
+
suthep setup
|
|
173
|
+
|
|
174
|
+
# Deploy
|
|
175
|
+
suthep deploy
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### 5. ตรวจสอบ
|
|
179
|
+
|
|
180
|
+
เปิด `https://api.yourdomain.com` ในเบราว์เซอร์ของคุณ คุณควรเห็น "Hello from Suthep!" และใบรับรอง SSL ควรจะถูกต้อง
|
|
181
|
+
|
|
182
|
+
## ขั้นตอนถัดไป
|
|
183
|
+
|
|
184
|
+
- อ่าน [คู่มืออ้างอิงการตั้งค่า](./configuration.md) เพื่อเรียนรู้เกี่ยวกับตัวเลือกการตั้งค่าทั้งหมด
|
|
185
|
+
- ดู [ตัวอย่าง](../en/examples.md) สำหรับสถานการณ์การ deploy ที่ซับซ้อนมากขึ้น *(English)*
|
|
186
|
+
- ตรวจสอบ [คู่มืออ้างอิงคำสั่ง](./commands.md) สำหรับเอกสารคำสั่งแบบละเอียด
|
|
187
|
+
|
|
188
|
+
## ปัญหาที่พบบ่อย
|
|
189
|
+
|
|
190
|
+
หากคุณพบปัญหาระหว่างการตั้งค่า:
|
|
191
|
+
|
|
192
|
+
1. **Permission denied**: ตรวจสอบว่าคุณมีสิทธิ์ sudo
|
|
193
|
+
2. **Nginx not found**: รัน `suthep setup` เพื่อติดตั้ง
|
|
194
|
+
3. **Domain not resolving**: ตรวจสอบว่า DNS ของ domain ชี้ไปที่ IP ของ server ของคุณ
|
|
195
|
+
4. **SSL certificate failed**: ตรวจสอบว่า domain ของคุณเข้าถึงได้จากสาธารณะและพอร์ต 80 เปิดอยู่
|
|
196
|
+
|
|
197
|
+
สำหรับความช่วยเหลือในการแก้ไขปัญหามากขึ้น ดู [คู่มือแก้ไขปัญหา](../en/troubleshooting.md) *(English)*
|
|
198
|
+
|
|
199
|
+
## ภาษาอื่นๆ / Other Languages
|
|
200
|
+
|
|
201
|
+
- [English](../en/getting-started.md) - English version / เวอร์ชันภาษาอังกฤษ
|
|
202
|
+
- [ไทย](./getting-started.md) - เวอร์ชันภาษาไทย (ปัจจุบัน)
|
|
203
|
+
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Local Docker Setup
|
|
2
|
+
|
|
3
|
+
This directory contains configuration files for running services locally with Docker.
|
|
4
|
+
|
|
5
|
+
## Files
|
|
6
|
+
|
|
7
|
+
- `example.yml` - Suthep deployment configuration
|
|
8
|
+
- `docker-compose.yml` - Docker Compose configuration for local development
|
|
9
|
+
|
|
10
|
+
## Quick Start
|
|
11
|
+
|
|
12
|
+
To run the services locally with Docker Compose:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Start all services
|
|
16
|
+
docker-compose up -d
|
|
17
|
+
|
|
18
|
+
# View logs
|
|
19
|
+
docker-compose logs -f
|
|
20
|
+
|
|
21
|
+
# Stop all services
|
|
22
|
+
docker-compose down
|
|
23
|
+
|
|
24
|
+
# Stop and remove volumes
|
|
25
|
+
docker-compose down -v
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Services
|
|
29
|
+
|
|
30
|
+
Based on `example.yml`, this Docker Compose file includes:
|
|
31
|
+
|
|
32
|
+
1. **webapp** (port 8080)
|
|
33
|
+
- Image: `nginx:latest`
|
|
34
|
+
- Container: `webapp-container`
|
|
35
|
+
- Maps to container port 80
|
|
36
|
+
|
|
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`
|
|
41
|
+
|
|
42
|
+
3. **postgres** (port 5432)
|
|
43
|
+
- Image: `postgres:latest`
|
|
44
|
+
- Container: `postgres-container`
|
|
45
|
+
- Database: `dashboard`
|
|
46
|
+
- Default credentials: `postgres/postgres`
|
|
47
|
+
|
|
48
|
+
4. **redis** (port 6379)
|
|
49
|
+
- Image: `redis:latest`
|
|
50
|
+
- Container: `redis-container`
|
|
51
|
+
|
|
52
|
+
## Notes
|
|
53
|
+
|
|
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
|
|
58
|
+
|
|
59
|
+
## Building Custom Images
|
|
60
|
+
|
|
61
|
+
If you need to build the dashboard image:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Build the dashboard image
|
|
65
|
+
docker build -t myapp/dashboard:latest ./path-to-dashboard
|
|
66
|
+
|
|
67
|
+
# Or update the docker-compose.yml to build from source:
|
|
68
|
+
# dashboard:
|
|
69
|
+
# build: ./path-to-dashboard
|
|
70
|
+
# ...
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Accessing Services
|
|
74
|
+
|
|
75
|
+
Once running, services are available at:
|
|
76
|
+
|
|
77
|
+
- Webapp: http://localhost:8080
|
|
78
|
+
- Dashboard: http://localhost:5000
|
|
79
|
+
- PostgreSQL: localhost:5432
|
|
80
|
+
- Redis: localhost:6379
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
project:
|
|
2
|
+
name: docker-ports-example
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
|
|
5
|
+
services:
|
|
6
|
+
# Example 1: Same port on host and container (3000:3000)
|
|
7
|
+
- name: api-same-port
|
|
8
|
+
port: 3000 # Host port: 3000
|
|
9
|
+
domains:
|
|
10
|
+
- api1.example.com
|
|
11
|
+
docker:
|
|
12
|
+
image: myapp/api:latest
|
|
13
|
+
container: api-same-port-container
|
|
14
|
+
port: 3000 # Container port: 3000
|
|
15
|
+
healthCheck:
|
|
16
|
+
path: /health
|
|
17
|
+
interval: 30
|
|
18
|
+
|
|
19
|
+
# Example 2: Different host and container ports (3002:3000)
|
|
20
|
+
- name: api-different-port
|
|
21
|
+
port: 3002 # Host port: 3002 (external access)
|
|
22
|
+
domains:
|
|
23
|
+
- api2.example.com
|
|
24
|
+
docker:
|
|
25
|
+
image: myapp/api:latest
|
|
26
|
+
container: api-different-port-container
|
|
27
|
+
port: 3000 # Container port: 3000 (app listens here inside)
|
|
28
|
+
healthCheck:
|
|
29
|
+
path: /health
|
|
30
|
+
interval: 30
|
|
31
|
+
|
|
32
|
+
# Example 3: Nginx with port mapping (8080:80)
|
|
33
|
+
- name: web
|
|
34
|
+
port: 8080 # Host port: 8080
|
|
35
|
+
domains:
|
|
36
|
+
- web.example.com
|
|
37
|
+
docker:
|
|
38
|
+
image: nginx:alpine
|
|
39
|
+
container: web-container
|
|
40
|
+
port: 80 # Container port: 80 (Nginx listens on 80)
|
|
41
|
+
healthCheck:
|
|
42
|
+
path: /
|
|
43
|
+
interval: 30
|
|
44
|
+
|
|
45
|
+
# Example 4: Multiple services with different ports
|
|
46
|
+
- name: service-a
|
|
47
|
+
port: 4000 # Host: 4000
|
|
48
|
+
domains:
|
|
49
|
+
- service-a.example.com
|
|
50
|
+
docker:
|
|
51
|
+
image: myapp/service-a:latest
|
|
52
|
+
container: service-a-container
|
|
53
|
+
port: 3000 # Container: 3000
|
|
54
|
+
healthCheck:
|
|
55
|
+
path: /health
|
|
56
|
+
interval: 30
|
|
57
|
+
|
|
58
|
+
- name: service-b
|
|
59
|
+
port: 4001 # Host: 4001
|
|
60
|
+
domains:
|
|
61
|
+
- service-b.example.com
|
|
62
|
+
docker:
|
|
63
|
+
image: myapp/service-b:latest
|
|
64
|
+
container: service-b-container
|
|
65
|
+
port: 3000 # Container: 3000 (can be same, containers are isolated)
|
|
66
|
+
healthCheck:
|
|
67
|
+
path: /health
|
|
68
|
+
interval: 30
|
|
69
|
+
|
|
70
|
+
nginx:
|
|
71
|
+
configPath: /etc/nginx/sites-available
|
|
72
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
73
|
+
|
|
74
|
+
certbot:
|
|
75
|
+
email: admin@example.com
|
|
76
|
+
staging: false
|
|
77
|
+
|
|
78
|
+
deployment:
|
|
79
|
+
strategy: rolling
|
|
80
|
+
healthCheckTimeout: 30000
|
|
81
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
project:
|
|
2
|
+
name: muacle-app
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
|
|
5
|
+
services:
|
|
6
|
+
# API service on /api path
|
|
7
|
+
- name: api
|
|
8
|
+
port: 3001
|
|
9
|
+
path: /api
|
|
10
|
+
domains:
|
|
11
|
+
- muacle.com
|
|
12
|
+
docker:
|
|
13
|
+
image: myapp/api:latest
|
|
14
|
+
container: api-container
|
|
15
|
+
port: 3001
|
|
16
|
+
healthCheck:
|
|
17
|
+
path: /health
|
|
18
|
+
interval: 30
|
|
19
|
+
environment:
|
|
20
|
+
NODE_ENV: production
|
|
21
|
+
|
|
22
|
+
# UI service on root path
|
|
23
|
+
- name: ui
|
|
24
|
+
port: 3000
|
|
25
|
+
path: /
|
|
26
|
+
domains:
|
|
27
|
+
- muacle.com
|
|
28
|
+
docker:
|
|
29
|
+
image: myapp/ui:latest
|
|
30
|
+
container: ui-container
|
|
31
|
+
port: 3000
|
|
32
|
+
healthCheck:
|
|
33
|
+
path: /
|
|
34
|
+
interval: 30
|
|
35
|
+
|
|
36
|
+
nginx:
|
|
37
|
+
configPath: /etc/nginx/sites-available
|
|
38
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
39
|
+
|
|
40
|
+
certbot:
|
|
41
|
+
email: admin@muacle.com
|
|
42
|
+
staging: false
|
|
43
|
+
|
|
44
|
+
deployment:
|
|
45
|
+
strategy: rolling
|
|
46
|
+
healthCheckTimeout: 30000
|
|
47
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
project:
|
|
2
|
+
name: port-binding-example
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
|
|
5
|
+
services:
|
|
6
|
+
# Example: Bind host port 3002 to container port 3000
|
|
7
|
+
- name: api
|
|
8
|
+
port: 3002 # Host port: accessible at localhost:3002
|
|
9
|
+
path: /api
|
|
10
|
+
domains:
|
|
11
|
+
- api.example.com
|
|
12
|
+
docker:
|
|
13
|
+
image: myapp/api:latest
|
|
14
|
+
container: api-container
|
|
15
|
+
port: 3000 # Container port: app listens on 3000 inside container
|
|
16
|
+
healthCheck:
|
|
17
|
+
path: /health
|
|
18
|
+
interval: 30
|
|
19
|
+
|
|
20
|
+
# Example: Same port on both host and container
|
|
21
|
+
- name: web
|
|
22
|
+
port: 8080 # Host port: 8080
|
|
23
|
+
path: /
|
|
24
|
+
domains:
|
|
25
|
+
- example.com
|
|
26
|
+
docker:
|
|
27
|
+
image: nginx:alpine
|
|
28
|
+
container: web-container
|
|
29
|
+
port: 80 # Container port: Nginx listens on 80 inside container
|
|
30
|
+
healthCheck:
|
|
31
|
+
path: /
|
|
32
|
+
interval: 30
|
|
33
|
+
|
|
34
|
+
nginx:
|
|
35
|
+
configPath: /etc/nginx/sites-available
|
|
36
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
37
|
+
|
|
38
|
+
certbot:
|
|
39
|
+
email: admin@example.com
|
|
40
|
+
staging: false
|
|
41
|
+
|
|
42
|
+
deployment:
|
|
43
|
+
strategy: rolling
|
|
44
|
+
healthCheckTimeout: 30000
|
|
45
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
project:
|
|
2
|
+
name: muacle-app
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
|
|
5
|
+
services:
|
|
6
|
+
# API service on /api path
|
|
7
|
+
- name: api
|
|
8
|
+
port: 3001
|
|
9
|
+
path: /api
|
|
10
|
+
domains:
|
|
11
|
+
- muacle.com
|
|
12
|
+
docker:
|
|
13
|
+
image: api:latest
|
|
14
|
+
container: api-container
|
|
15
|
+
port: 3001
|
|
16
|
+
# healthCheck:
|
|
17
|
+
# path: /health
|
|
18
|
+
# interval: 30
|
|
19
|
+
environment:
|
|
20
|
+
NODE_ENV: production
|
|
21
|
+
|
|
22
|
+
# UI service on root path
|
|
23
|
+
- name: ui
|
|
24
|
+
port: 3002
|
|
25
|
+
path: /
|
|
26
|
+
domains:
|
|
27
|
+
- muacle.com
|
|
28
|
+
docker:
|
|
29
|
+
image: frontend-api:latest
|
|
30
|
+
container: ui-container
|
|
31
|
+
port: 3000
|
|
32
|
+
# healthCheck:
|
|
33
|
+
# path: /
|
|
34
|
+
# interval: 30
|
|
35
|
+
|
|
36
|
+
nginx:
|
|
37
|
+
configPath: /etc/nginx/sites-available
|
|
38
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
39
|
+
|
|
40
|
+
certbot:
|
|
41
|
+
email: admin@muacle.com
|
|
42
|
+
staging: false
|
|
43
|
+
|
|
44
|
+
deployment:
|
|
45
|
+
strategy: rolling
|
|
46
|
+
healthCheckTimeout: 30000
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
project:
|
|
2
|
+
name: my-app
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
|
|
5
|
+
services:
|
|
6
|
+
# Example 1: Simple Node.js service
|
|
7
|
+
- name: api
|
|
8
|
+
port: 3001
|
|
9
|
+
docker:
|
|
10
|
+
image: muacle-api:latest
|
|
11
|
+
container: api
|
|
12
|
+
port: 3000
|
|
13
|
+
domains:
|
|
14
|
+
- x.muacle.com
|
|
15
|
+
healthCheck:
|
|
16
|
+
path: /api/v1/health
|
|
17
|
+
interval: 30
|
|
18
|
+
environment:
|
|
19
|
+
NODE_ENV: production
|
|
20
|
+
PORT: 3001
|
|
21
|
+
|
|
22
|
+
# Example 2: Docker container service
|
|
23
|
+
- name: webapp
|
|
24
|
+
port: 3000
|
|
25
|
+
docker:
|
|
26
|
+
image: muacle-frontend:latest
|
|
27
|
+
container: frontend
|
|
28
|
+
port: 3000
|
|
29
|
+
domains:
|
|
30
|
+
- x.muacle.com
|
|
31
|
+
healthCheck:
|
|
32
|
+
path: /
|
|
33
|
+
interval: 30
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
nginx:
|
|
37
|
+
configPath: /etc/nginx/sites-available
|
|
38
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
39
|
+
|
|
40
|
+
certbot:
|
|
41
|
+
email: admin@example.com
|
|
42
|
+
staging: false # Set to true for testing
|
|
43
|
+
|
|
44
|
+
deployment:
|
|
45
|
+
strategy: rolling # Options: rolling, blue-green
|
|
46
|
+
healthCheckTimeout: 30000 # milliseconds
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "suthep",
|
|
3
|
+
"version": "0.1.0-beta.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "CLI tool for deploying projects with automatic Nginx reverse proxy and HTTPS setup",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"suthep": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"dev": "vite",
|
|
12
|
+
"build": "tsc && vite build",
|
|
13
|
+
"test": "npm run build && node dist/index.js --help",
|
|
14
|
+
"prepublishOnly": "npm run build"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"deploy",
|
|
18
|
+
"nginx",
|
|
19
|
+
"certbot",
|
|
20
|
+
"docker",
|
|
21
|
+
"cli"
|
|
22
|
+
],
|
|
23
|
+
"author": "",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"chalk": "^5.6.2",
|
|
27
|
+
"commander": "^14.0.2",
|
|
28
|
+
"execa": "^9.6.1",
|
|
29
|
+
"fs-extra": "^11.3.2",
|
|
30
|
+
"inquirer": "^13.0.2",
|
|
31
|
+
"js-yaml": "^4.1.1",
|
|
32
|
+
"vite": "^7.2.7"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/fs-extra": "^11.0.4",
|
|
36
|
+
"@types/inquirer": "^9.0.9",
|
|
37
|
+
"@types/js-yaml": "^4.0.9",
|
|
38
|
+
"@types/node": "^24.10.1",
|
|
39
|
+
"tsx": "^4.21.0",
|
|
40
|
+
"typescript": "^5.9.3"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=16.0.0"
|
|
44
|
+
}
|
|
45
|
+
}
|