@gravito/launchpad 1.0.0 → 1.1.0
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/CHANGELOG.md +16 -0
- package/README.md +79 -21
- package/dist/index.d.mts +17 -0
- package/dist/index.d.ts +17 -0
- package/package.json +1 -1
- package/src/Application/MissionControl.ts +1 -0
- package/src/Domain/Interfaces.ts +20 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @gravito/launchpad
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Launch standalone high-performance engine and core optimizations.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- q
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @gravito/core@1.1.0
|
|
15
|
+
- @gravito/enterprise@1.0.1
|
|
16
|
+
- @gravito/ripple@2.0.0
|
|
17
|
+
- @gravito/stasis@2.0.0
|
|
18
|
+
|
|
3
19
|
## 1.0.0
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,44 +1,102 @@
|
|
|
1
1
|
# @gravito/launchpad
|
|
2
2
|
|
|
3
|
-
> 🚀
|
|
3
|
+
> 🚀 Instant Deployment System for Bun. Container lifecycle management and zero-downtime deployment.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Gravito Launchpad** is a specialized orchestration system built for the Bun runtime. It uses a unique "Rocket Pool" architecture to pre-warm containers, enabling sub-second deployments by injecting code into already running instances instead of building images from scratch.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- **Payload Injection**: 跳過 Docker Build,透過 `docker cp` 秒級注入代碼。
|
|
9
|
-
- **DDD 架構**: 基於 `@gravito/enterprise` 實作,具備嚴謹的狀態機管理。
|
|
10
|
-
- **可回收性**: 任務結束後自動翻新容器,資源零浪費。
|
|
7
|
+
## ✨ Core Features
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
- **🔥 Rocket Pool**: Pre-warmed container pool eliminates cold start times.
|
|
10
|
+
- **💉 Payload Injection**: Skip `docker build`. Code is injected via `docker cp` in milliseconds.
|
|
11
|
+
- **🏗️ DDD Architecture**: Built on `@gravito/enterprise` with rigorous state machine management.
|
|
12
|
+
- **♻️ Auto-Recycling**: Containers are automatically refurbished and returned to the pool after missions.
|
|
13
|
+
- **🤖 GitHub Integration**: Built-in webhook handler for PR previews and automated comments.
|
|
14
|
+
- **🛡️ Secure Isolation**: Each deployment runs in an isolated container environment.
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
## 🏗️ Architecture Overview
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
- **Application**: `PoolManager` (調度) 與 `PayloadInjector` (部署)。
|
|
18
|
-
- **Infrastructure**: 底層 Docker 與 Git 操作實作。
|
|
18
|
+
Launchpad follows **Clean Architecture** principles:
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
### Domain Layer
|
|
21
|
+
- **Rocket**: The aggregate root representing a container instance.
|
|
22
|
+
- **Mission**: Represents a deployment task (repo, commit, branch).
|
|
23
|
+
- **Status Machine**: Strictly manages transitions (Idle -> Assigned -> Deployed -> Recycling).
|
|
24
|
+
|
|
25
|
+
### Application Layer
|
|
26
|
+
- **PoolManager**: Orchestrates the lifecycle of Rockets (warmup, assignment, recycling).
|
|
27
|
+
- **PayloadInjector**: Handles the git clone and code injection process.
|
|
28
|
+
- **MissionControl**: High-level facade for launching missions.
|
|
29
|
+
- **RefurbishUnit**: Cleans up used containers for reuse.
|
|
30
|
+
|
|
31
|
+
### Infrastructure Layer
|
|
32
|
+
- **DockerAdapter**: Low-level communication with Docker daemon.
|
|
33
|
+
- **ShellGitAdapter**: Git operations via shell commands.
|
|
34
|
+
- **BunProxyAdapter**: Manages reverse proxying to active containers.
|
|
35
|
+
|
|
36
|
+
## 🚀 Quick Start
|
|
37
|
+
|
|
38
|
+
### Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
bun add @gravito/launchpad
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Basic Usage
|
|
21
45
|
|
|
22
46
|
```typescript
|
|
23
|
-
import { PoolManager, PayloadInjector } from '@gravito/launchpad'
|
|
47
|
+
import { PoolManager, PayloadInjector, Mission } from '@gravito/launchpad'
|
|
24
48
|
import { DockerAdapter, ShellGitAdapter, InMemoryRocketRepository } from '@gravito/launchpad/infra'
|
|
25
49
|
|
|
26
|
-
|
|
27
|
-
const
|
|
50
|
+
// Initialize adapters
|
|
51
|
+
const docker = new DockerAdapter()
|
|
52
|
+
const repo = new InMemoryRocketRepository()
|
|
53
|
+
const manager = new PoolManager(docker, repo)
|
|
28
54
|
|
|
29
|
-
// 1.
|
|
55
|
+
// 1. Warmup the pool (Create 3 idle containers)
|
|
30
56
|
await manager.warmup(3)
|
|
31
57
|
|
|
32
|
-
// 2.
|
|
33
|
-
const mission = Mission.create({
|
|
34
|
-
|
|
58
|
+
// 2. Create a mission
|
|
59
|
+
const mission = Mission.create({
|
|
60
|
+
id: 'mission-1',
|
|
61
|
+
repoUrl: 'https://github.com/user/repo.git',
|
|
62
|
+
commitSha: 'latest'
|
|
63
|
+
})
|
|
35
64
|
|
|
36
|
-
// 3.
|
|
65
|
+
// 3. Launch! (Assigns a rocket and injects code)
|
|
66
|
+
const rocket = await manager.assignMission(mission)
|
|
67
|
+
const injector = new PayloadInjector(docker, new ShellGitAdapter())
|
|
37
68
|
await injector.deploy(rocket)
|
|
69
|
+
|
|
70
|
+
console.log(`Mission deployed to http://localhost:${rocket.port}`)
|
|
38
71
|
```
|
|
39
72
|
|
|
40
|
-
|
|
73
|
+
### Running as a Service (Orbit)
|
|
74
|
+
|
|
75
|
+
Launchpad can run as a Gravito Orbit, providing a REST API and Webhook support.
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { bootstrapLaunchpad } from '@gravito/launchpad'
|
|
79
|
+
|
|
80
|
+
const { port } = await bootstrapLaunchpad()
|
|
81
|
+
console.log(`Launchpad Server running on port ${port}`)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## ⚙️ Configuration
|
|
85
|
+
|
|
86
|
+
Launchpad relies on Docker. Ensure Docker is installed and running.
|
|
87
|
+
|
|
88
|
+
| Environment Variable | Description | Default |
|
|
89
|
+
|----------------------|-------------|---------|
|
|
90
|
+
| `GITHUB_TOKEN` | Token for GitHub API access | (Required for PR comments) |
|
|
91
|
+
| `GITHUB_WEBHOOK_SECRET` | Secret for verifying webhooks | (Optional) |
|
|
92
|
+
| `POOL_SIZE` | Target number of pre-warmed containers | `3` |
|
|
93
|
+
|
|
94
|
+
## 🧪 Testing
|
|
41
95
|
|
|
42
96
|
```bash
|
|
43
97
|
bun test
|
|
44
98
|
```
|
|
99
|
+
|
|
100
|
+
## 📄 License
|
|
101
|
+
|
|
102
|
+
MIT © Gravito Framework
|
package/dist/index.d.mts
CHANGED
|
@@ -104,6 +104,23 @@ interface IDockerAdapter {
|
|
|
104
104
|
interface IGitAdapter {
|
|
105
105
|
clone(repoUrl: string, branch: string): Promise<string>;
|
|
106
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* 負責動態反向代理與域名路由的轉接器
|
|
109
|
+
*/
|
|
110
|
+
interface IRouterAdapter {
|
|
111
|
+
/**
|
|
112
|
+
* 註冊一個域名映射到指定的目標 (URL)
|
|
113
|
+
*/
|
|
114
|
+
register(domain: string, targetUrl: string): void;
|
|
115
|
+
/**
|
|
116
|
+
* 註銷域名
|
|
117
|
+
*/
|
|
118
|
+
unregister(domain: string): void;
|
|
119
|
+
/**
|
|
120
|
+
* 啟動代理伺服器
|
|
121
|
+
*/
|
|
122
|
+
start(port: number): void;
|
|
123
|
+
}
|
|
107
124
|
/**
|
|
108
125
|
* 負責動態反向代理與域名路由的轉接器
|
|
109
126
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -104,6 +104,23 @@ interface IDockerAdapter {
|
|
|
104
104
|
interface IGitAdapter {
|
|
105
105
|
clone(repoUrl: string, branch: string): Promise<string>;
|
|
106
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* 負責動態反向代理與域名路由的轉接器
|
|
109
|
+
*/
|
|
110
|
+
interface IRouterAdapter {
|
|
111
|
+
/**
|
|
112
|
+
* 註冊一個域名映射到指定的目標 (URL)
|
|
113
|
+
*/
|
|
114
|
+
register(domain: string, targetUrl: string): void;
|
|
115
|
+
/**
|
|
116
|
+
* 註銷域名
|
|
117
|
+
*/
|
|
118
|
+
unregister(domain: string): void;
|
|
119
|
+
/**
|
|
120
|
+
* 啟動代理伺服器
|
|
121
|
+
*/
|
|
122
|
+
start(port: number): void;
|
|
123
|
+
}
|
|
107
124
|
/**
|
|
108
125
|
* 負責動態反向代理與域名路由的轉接器
|
|
109
126
|
*/
|
package/package.json
CHANGED
package/src/Domain/Interfaces.ts
CHANGED
|
@@ -26,6 +26,26 @@ export interface IDockerAdapter {
|
|
|
26
26
|
getStats(containerId: string): Promise<{ cpu: string; memory: string }>
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* 負責動態反向代理與域名路由的轉接器
|
|
31
|
+
*/
|
|
32
|
+
export interface IRouterAdapter {
|
|
33
|
+
/**
|
|
34
|
+
* 註冊一個域名映射到指定的目標 (URL)
|
|
35
|
+
*/
|
|
36
|
+
register(domain: string, targetUrl: string): void
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 註銷域名
|
|
40
|
+
*/
|
|
41
|
+
unregister(domain: string): void
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 啟動代理伺服器
|
|
45
|
+
*/
|
|
46
|
+
start(port: number): void
|
|
47
|
+
}
|
|
48
|
+
|
|
29
49
|
/**
|
|
30
50
|
* 負責代碼獲取
|
|
31
51
|
*/
|