@h-ai/deploy 0.1.0-alpha.66 → 0.1.0-alpha.67
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.en.md +97 -37
- package/README.ja.md +97 -37
- package/README.md +101 -78
- package/dist/index.d.ts +13 -3
- package/dist/index.js +547 -113
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.en.md
CHANGED
|
@@ -2,78 +2,138 @@
|
|
|
2
2
|
|
|
3
3
|
[简体中文](README.md) | [English](README.en.md) | [日本語](README.ja.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Introduction
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Deploy existing images or Vercel prebuilt output, including complete offline bundles, selected service updates, SSH automation and platform upload scripts. The SDK consumes artifacts; CLI --build explicitly orchestrates build then deployment.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Core features
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
- Build, package, upload over SSH, start services and check access from one CLI command.
|
|
12
|
+
- Include application and self-hosted middleware images, or update selected services.
|
|
13
|
+
- Deliver offline tar bundles with Windows/Linux/macOS operator scripts, step results and recovery on failure.
|
|
14
|
+
|
|
15
|
+
## Getting started
|
|
16
|
+
|
|
17
|
+
### Prepare build artifacts
|
|
18
|
+
|
|
19
|
+
Projects include deployment tooling by default; use `hai create my-app --no-deploy` to opt out. The deployment SDK is a development dependency and is excluded from runtime images.
|
|
12
20
|
|
|
13
21
|
```sh
|
|
14
|
-
pnpm build
|
|
15
|
-
pnpm build --target docker
|
|
16
|
-
pnpm build --target docker --
|
|
22
|
+
pnpm build
|
|
23
|
+
pnpm build --target docker
|
|
24
|
+
pnpm build --target docker --images web
|
|
17
25
|
pnpm build --target desktop --platform windows --arch x64
|
|
18
26
|
```
|
|
19
27
|
|
|
20
|
-
|
|
28
|
+
#### Build options
|
|
21
29
|
|
|
22
|
-
|
|
30
|
+
`--target` selects compile (default), docker or desktop. `--images app|web|app,web` selects images. `--runtime auto|podman|docker` selects the local engine; auto prefers reachable Podman. `--network` overrides build networking, `--no-http-proxy` disables inherited Podman proxies, and `--sqlite-prebuild-mirror` selects a trusted HTTP(S) binary mirror. Native `--platform` and `--arch` require the matching host SDK and Rust toolchain. Builds do not load deployment environments or runtime secrets.
|
|
23
31
|
|
|
24
|
-
|
|
32
|
+
#### Describe packaging in hai.build.json
|
|
25
33
|
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
pnpm run deploy --env prod --artifact-dir .hai/build/docker/<buildId> --skip-middleware
|
|
29
|
-
pnpm run deploy --env prod --bundle-only --output release-prod.tar
|
|
30
|
-
# equivalent fullstack CLI invocation
|
|
31
|
-
pnpm exec hai deploy packages/my-app-serv --env prod --env-dir .
|
|
34
|
+
```json
|
|
35
|
+
{ "images": [{ "name": "app", "context": ".", "dockerfile": "images/app.Dockerfile", "containerPort": 3000 }, { "name": "web", "context": ".", "dockerfile": "images/web.Dockerfile", "containerPort": 8080 }] }
|
|
32
36
|
```
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
Each image has its own Dockerfile. Web runtime assets live in images/web/. Dockerfiles retain internal build/runtime stages; configuration does not select stages. Omit absent images and add desktop directories only for native projects.
|
|
39
|
+
|
|
40
|
+
Dependency inputs are prepared under images/dependencies/ from package manifests, local archives and patches. Combine pnpm store caching with stable dependency layers. Source changes should reuse downloaded packages. Empty caches still permit online builds. Windows node_modules cannot supply Linux native dependencies. Offline builds additionally require base images, tools and matching ABI/architecture/libc binaries.
|
|
35
41
|
|
|
36
|
-
The
|
|
42
|
+
The root package.json.version identifies the application. `.hai/build/docker/<buildId>/` contains manifest format 3, selected image archives and SHA-256. partial marks incremental builds and hasWeb records topology. appContainerPort and webContainerPort retain explicitly configured app/web listening ports, including the image left out of a partial build. Omitted ports keep the deployment defaults. Rebuilding the same application version is allowed; unique build IDs/image references distinguish contents. Publish the local build pointer only after all exports succeed. Pin base images, middleware and tools; do not use latest.
|
|
43
|
+
|
|
44
|
+
### Deploy artifacts
|
|
45
|
+
|
|
46
|
+
#### Prepare the environment and destination
|
|
47
|
+
|
|
48
|
+
Prepare `.env.<environment>` and the service config/_deploy.yml. Fullstack deploy scripts point to packages/<project>-serv; API workspaces use apps/<project>-service. Artifact lookup remains rooted at the build configuration.
|
|
49
|
+
|
|
50
|
+
```yaml
|
|
51
|
+
provider:
|
|
52
|
+
type: docker-ssh
|
|
53
|
+
expose:
|
|
54
|
+
hostPort: 18080
|
|
55
|
+
container:
|
|
56
|
+
s3Engine: rustfs
|
|
57
|
+
```
|
|
37
58
|
|
|
38
|
-
|
|
59
|
+
The wizard asks for server address, SSH user, optional key/fingerprint files and public port using readable labels. Reuse valid settings; local connection settings go to .env.local, private keys are referenced by path. Bundle-only does not require SSH.
|
|
39
60
|
|
|
40
|
-
|
|
61
|
+
#### Configure only the middleware the application needs
|
|
41
62
|
|
|
42
|
-
|
|
63
|
+
Runtime lockfile dependencies and configuration determine middleware. Choose defaults, custom connections or keep settings. --skip-middleware skips configuration/provisioning. SQLite, memory cache and local storage need no external images. Complete bundles automatically include self-hosted middleware images. External services still require reachable destinations; cloud provisioning is not an offline operation.
|
|
43
64
|
|
|
44
|
-
|
|
65
|
+
#### Deployment options
|
|
45
66
|
|
|
46
|
-
|
|
67
|
+
--env/--env-dir select configuration. --build builds selected application images before packaging. --services selects Compose services; --artifact-dir selects existing artifacts. --bundle-only creates a tar and platform scripts without SSH. --runtime selects the local build/export engine; --output selects the version-suffixed archive name. --yes uses valid settings without interaction and reports missing required values.
|
|
68
|
+
|
|
69
|
+
#### When the machines can connect: automatic deployment
|
|
47
70
|
|
|
48
71
|
```sh
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
HAI_DEPLOY_PROVIDER_REMOTE_RUNTIME=docker sh start-prod.sh
|
|
72
|
+
pnpm run deploy --env prod --build
|
|
73
|
+
pnpm run deploy --env prod --artifact-dir .hai/build/docker/<buildId>
|
|
74
|
+
pnpm run deploy --env prod --build --services web
|
|
53
75
|
```
|
|
54
76
|
|
|
55
|
-
|
|
77
|
+
Partial updates require a successful full server installation and matching ports/layout. Merge selected services into the server's successful baseline; preserve unselected services, settings and volumes. The deployment script first removes only the selected old containers by project and service labels, retaining their volumes. It then runs `compose up -d --no-deps --no-build --pull never --no-recreate web` to create replacements while other containers keep running, without project-wide down. storage-init is a one-time S3 bucket initialization task, executed only when storage initialization is selected.
|
|
56
78
|
|
|
57
|
-
|
|
79
|
+
Here `-d` starts in the background; `--no-deps` leaves dependencies untouched; `--no-build` prevents server builds; `--pull never` forbids registry pulls; `--no-recreate` preserves containers that still exist; the selected old containers were already removed by the script, so their replacements are created. `web` is a Compose service name, not an image tag; separate multiple services with spaces.
|
|
58
80
|
|
|
59
|
-
|
|
81
|
+
`storage-init` uses the application's S3 SDK to wait for storage and create a missing bucket without deleting data. Start storage first, then run `compose up --no-deps --no-build --pull never --force-recreate --exit-code-from storage-init storage-init`. Start selected application services only after initialization exits with zero. For partial updates, the script first removes the old storage-init container and uses `--no-recreate` instead of `--force-recreate` here, preserving running application containers. Updating only `storage` still requires an artifact containing the `app` image for initialization. If the most recent build contains only Web, select the original complete artifact with `--artifact-dir`, or run `pnpm build --target docker --images app` first. This image is used for initialization without updating the running `app` service.
|
|
60
82
|
|
|
61
|
-
|
|
83
|
+
#### When the machines cannot connect: copy a bundle
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
pnpm run deploy --env prod --build --bundle-only --output release-prod.tar
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Application 1.2.3 produces release-prod-1.2.3.tar and an adjacent -deploy/ directory. The tar includes selected application/middleware images, configurations, private environment files, checksums, README and apply.sh. Run deploy.ps1 on Windows or deploy.sh on Linux/macOS to upload using saved SSH settings and execute the same server workflow. After moving to another computer or operating system, update both the private key and known-hosts paths to files on that computer. On Windows, edit deploy-target.json; on Linux/macOS, set HAI_DEPLOY_IDENTITY_FILE and HAI_DEPLOY_KNOWN_HOSTS_FILE.
|
|
90
|
+
|
|
91
|
+
On isolated Linux servers, extract into a separate package directory and run `sh apply.sh`, optionally passing the deployment root. Every failed step exits nonzero. Image loading, service startup and HTTP checks are distinct steps. result-<deploymentId>.json records the result; current changes only after successful checks. Reapplying the same deployment ID stops clearly; a newly generated bundle for the same application version is allowed. Failed updates attempt to restore selected containers and configuration while preserving data volumes and diagnostics. Data already written by the application is not rolled back.
|
|
92
|
+
|
|
93
|
+
#### Before going fully offline
|
|
94
|
+
|
|
95
|
+
Complete bundles include self-hosted middleware archives and matching architecture; server startup never pulls images. Linux needs Docker/Podman, Docker Compose v2 or podman-compose 1.6.0+ (supports --pull never), sh, tar, sha256sum, awk, curl and filesystem/container permissions. Protect private bundle contents. Keep volume identities stable across versions. Verify actual offline startup, login, refresh, restart and persistence. HTTPS, certificates, DNS and external services need separate preparation.
|
|
96
|
+
|
|
97
|
+
### SDK
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import { deploy } from '@h-ai/deploy'
|
|
101
|
+
|
|
102
|
+
const initialized = await deploy.init({ provider: { type: 'docker-ssh', expose: { hostPort: 18080 } } })
|
|
103
|
+
if (!initialized.success)
|
|
104
|
+
throw new Error(initialized.error.message)
|
|
105
|
+
try {
|
|
106
|
+
const result = await deploy.deployApp('./packages/demo-serv', {
|
|
107
|
+
environment: 'prod',
|
|
108
|
+
envDir: '.',
|
|
109
|
+
bundleOnly: true,
|
|
110
|
+
artifactDir: './.hai/build/docker/<buildId>',
|
|
111
|
+
runtime: 'auto',
|
|
112
|
+
})
|
|
113
|
+
if (!result.success)
|
|
114
|
+
throw new Error(result.error.message)
|
|
115
|
+
// result.data.bundlePath / instructions; packaged does not mean server ready.
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
await deploy.close()
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`selectedServices: ['web']` selects a partial update. `onProgress` receives actual packaging/server stages. `deploy.scan` and `deploy.credentials.*` are available before init. Check HaiResult.success before using data. Vercel uploads existing .vercel/output through the prebuilt API and requires internet; it does not provide offline or Compose partial deployment.
|
|
123
|
+
|
|
124
|
+
## Development and testing
|
|
62
125
|
|
|
63
126
|
```sh
|
|
64
127
|
pnpm --filter @h-ai/deploy typecheck
|
|
65
128
|
pnpm --filter @h-ai/deploy lint
|
|
66
129
|
pnpm --filter @h-ai/deploy build
|
|
67
130
|
pnpm --filter @h-ai/deploy test
|
|
68
|
-
pnpm --filter @h-ai/cli test
|
|
69
131
|
pnpm --filter @h-ai/cli test:scaffold-gates
|
|
70
132
|
pnpm --filter @h-ai/cli test:deploy-gates
|
|
71
133
|
```
|
|
72
134
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
Deploy gates do not forward host proxies by default. To download build dependencies through a proxy, set test-only `HAI_DEPLOY_E2E_CONTAINER_PROXY` (unset by default), for example `$env:HAI_DEPLOY_E2E_CONTAINER_PROXY='http://host.containers.internal:10808'` in PowerShell for Windows Podman. The address must be reachable from build containers; it is not written to application configuration or release images.
|
|
135
|
+
Run actual generated projects and SSH/manual deployment, including an isolated registry environment, incremental updates, damaged archives, same-version releases and failed health checks. Clean only test-owned projects, images, containers, logs and processes in finally/teardown.
|
|
76
136
|
|
|
77
|
-
|
|
137
|
+
## License
|
|
78
138
|
|
|
79
|
-
|
|
139
|
+
Apache-2.0
|
package/README.ja.md
CHANGED
|
@@ -2,78 +2,138 @@
|
|
|
2
2
|
|
|
3
3
|
[简体中文](README.md) | [English](README.en.md) | [日本語](README.ja.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## 概要
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
既存イメージまたは Vercel prebuilt 成果物を配布します。完全オフライン、サービス選択、SSH 自動化、OS 別の手動配布スクリプトに対応します。SDK は成果物を消費し、CLI --build は構築から配布を明示的に実行します。
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## 主な機能
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
- CLI でビルド、梱包、SSH 転送、起動、アクセス確認を実行。
|
|
12
|
+
- アプリと自前ミドルウェアのイメージを同梱し、選択したサービスだけの更新にも対応。
|
|
13
|
+
- オフライン用 tar と Windows/Linux/macOS 操作スクリプトを生成し、手順の結果と失敗時の復元を扱う。
|
|
14
|
+
|
|
15
|
+
## 使い始める
|
|
16
|
+
|
|
17
|
+
### 4. ソースをコンパイルし、配布物を作る
|
|
18
|
+
|
|
19
|
+
デプロイツールは作成時に既定で含まれます。不要な場合は `hai create my-app --no-deploy` を指定します。SDK は開発依存に配置し、実行イメージには含めません。
|
|
12
20
|
|
|
13
21
|
```sh
|
|
14
|
-
pnpm build
|
|
15
|
-
pnpm build --target docker
|
|
16
|
-
pnpm build --target docker --
|
|
22
|
+
pnpm build
|
|
23
|
+
pnpm build --target docker
|
|
24
|
+
pnpm build --target docker --images web
|
|
17
25
|
pnpm build --target desktop --platform windows --arch x64
|
|
18
26
|
```
|
|
19
27
|
|
|
20
|
-
|
|
28
|
+
#### build のオプション
|
|
21
29
|
|
|
22
|
-
|
|
30
|
+
`--target` は compile(既定)、docker、desktop を選択します。`--images app|web|app,web` は対象イメージを、`--runtime auto|podman|docker` はローカルエンジンを選択します。auto は接続可能な Podman を優先します。`--network` は構築ネットワーク、`--no-http-proxy` は Podman のプロキシ継承無効、`--sqlite-prebuild-mirror` は信頼できる HTTP(S) バイナリ配布元です。ネイティブ配布物には対象 OS の SDK と Rust ツールチェーンが必要です。構築時にデプロイ環境や秘密情報を読み込みません。
|
|
23
31
|
|
|
24
|
-
|
|
32
|
+
#### hai.build.json でパッケージの構成を指定する
|
|
25
33
|
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
pnpm run deploy --env prod --artifact-dir .hai/build/docker/<buildId> --skip-middleware
|
|
29
|
-
pnpm run deploy --env prod --bundle-only --output release-prod.tar
|
|
30
|
-
# fullstack で同じ処理を直接呼ぶ場合
|
|
31
|
-
pnpm exec hai deploy packages/my-app-serv --env prod --env-dir .
|
|
34
|
+
```json
|
|
35
|
+
{ "images": [{ "name": "app", "context": ".", "dockerfile": "images/app.Dockerfile", "containerPort": 3000 }, { "name": "web", "context": ".", "dockerfile": "images/web.Dockerfile", "containerPort": 8080 }] }
|
|
32
36
|
```
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
各イメージに独立した Dockerfile を用意します。Web 用設定は images/web/ に置きます。Dockerfile 内の構築・実行段階は維持しますが、設定から段階を選びません。不要なイメージ項目は削除し、desktop ディレクトリは対象プロジェクトのみ設定します。
|
|
39
|
+
|
|
40
|
+
構築器はパッケージ情報、ローカルアーカイブとパッチを images/dependencies/ に準備し、pnpm store と依存レイヤーをキャッシュします。通常のソース変更で全依存を再ダウンロードしない構成です。キャッシュが空でもオンライン構築できます。Windows の node_modules は Linux のネイティブ依存を代替できません。完全オフライン構築には基底イメージ、ツールと一致する ABI・アーキテクチャ・libc のバイナリも準備します。
|
|
35
41
|
|
|
36
|
-
|
|
42
|
+
アプリの版はルート package.json.version で管理します。`.hai/build/docker/<buildId>/` に形式 3 の manifest.json、選択イメージの tar と SHA-256 を出力します。partial は部分構築、hasWeb は構成を記録します。appContainerPort と webContainerPort は明示した app/web の待受ポートを保持し、部分構築で選ばなかったイメージのポートも失いません。未指定のポートにはデプロイ時の既定値を使います。同じアプリ版でも再構築可能で、構築 ID とイメージ参照で内容を区別します。全出力に成功してからローカルの構築参照を更新します。基底・ミドルウェア・ツールは版を固定し、latest を使いません。
|
|
43
|
+
|
|
44
|
+
### 5. 成果物を対象環境へデプロイする
|
|
45
|
+
|
|
46
|
+
#### 環境と接続先を用意する
|
|
47
|
+
|
|
48
|
+
`.env.<環境>` とサービスの config/_deploy.yml を用意します。fullstack の deploy は packages/<プロジェクト>-serv、API workspace は apps/<プロジェクト>-service を指定します。これは設定と実行依存の走査入口で、成果物は構築設定のルートから読み込みます。
|
|
49
|
+
|
|
50
|
+
```yaml
|
|
51
|
+
provider:
|
|
52
|
+
type: docker-ssh
|
|
53
|
+
expose:
|
|
54
|
+
hostPort: 18080
|
|
55
|
+
container:
|
|
56
|
+
s3Engine: rustfs
|
|
57
|
+
```
|
|
37
58
|
|
|
38
|
-
|
|
59
|
+
ウィザードはサーバー、SSH ユーザー、任意の鍵・指紋ファイル、公開ポートを説明付きで質問します。有効な設定は再利用し、接続情報は .env.local、秘密鍵はパスのみ保存します。パッケージ生成だけなら SSH は不要です。
|
|
39
60
|
|
|
40
|
-
|
|
61
|
+
#### 本当に必要なミドルウェアだけを設定する
|
|
41
62
|
|
|
42
|
-
|
|
63
|
+
実行依存と設定に基づき、既定、自分の接続、設定維持を選びます。--skip-middleware は設定と開通を省略します。SQLite、メモリーキャッシュ、ローカル保存には外部イメージがありません。完全配布物には自前ミドルウェアのイメージも自動で含めます。外部サービスは接続先への到達性が必要で、クラウド開通はオフライン処理ではありません。
|
|
43
64
|
|
|
44
|
-
|
|
65
|
+
#### deploy のオプション
|
|
45
66
|
|
|
46
|
-
|
|
67
|
+
--env/--env-dir は環境、--build は先行する選択イメージ構築、--services は更新対象、--artifact-dir は既存成果物を指定します。--bundle-only は SSH 接続なしで tar と OS 別スクリプトを生成します。--runtime はローカル構築・イメージ出力エンジン、--output は版付きファイル名です。--yes は有効な設定を非対話で使い、不足値はエラーで示します。一体化構築でも --network、--no-http-proxy、--sqlite-prebuild-mirror を指定できます。
|
|
68
|
+
|
|
69
|
+
#### マシン同士が接続できる場合:自動デプロイ
|
|
47
70
|
|
|
48
71
|
```sh
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
HAI_DEPLOY_PROVIDER_REMOTE_RUNTIME=docker sh start-prod.sh
|
|
72
|
+
pnpm run deploy --env prod --build
|
|
73
|
+
pnpm run deploy --env prod --artifact-dir .hai/build/docker/<buildId>
|
|
74
|
+
pnpm run deploy --env prod --build --services web
|
|
53
75
|
```
|
|
54
76
|
|
|
55
|
-
|
|
77
|
+
部分更新には成功済みの完全インストールと一致するポート・構成が必要です。Compose 標準の設定合成で未選択サービス、設定、ボリュームを保持します。スクリプトはプロジェクト名とサービス名で選択した旧コンテナーだけを削除し、ボリュームを保持します。その後 `compose up -d --no-deps --no-build --pull never --no-recreate web` で新しいコンテナーを作成します。他のコンテナーは稼働したままで、全体の down は実行しません。storage-init は S3 バケットの一時初期化処理で、ストレージ初期化を伴う場合に限り実行します。
|
|
56
78
|
|
|
57
|
-
|
|
79
|
+
`-d` はバックグラウンド起動、`--no-deps` は依存サービスを更新しない指定、`--no-build` はサーバーでの構築禁止、`--pull never` は取得禁止、`--no-recreate` は残っているコンテナーを保持します。選択した旧コンテナーは事前に削除されているため、新しいコンテナーが作成されます。末尾の `web` は Compose サービス名で、複数指定は空白で区切ります。
|
|
58
80
|
|
|
59
|
-
|
|
81
|
+
`storage-init` はアプリの S3 SDK でストレージの準備を待ち、不足するバケットを作成します。既存データは削除しません。storage 起動後に `compose up --no-deps --no-build --pull never --force-recreate --exit-code-from storage-init storage-init` を実行し、終了コード 0 を確認してアプリを起動します。 部分更新では旧 storage-init コンテナーを先に削除し、このコマンドの `--force-recreate` を `--no-recreate` に替えて、稼働中のアプリを保持します。`storage` だけを更新する場合も、初期化のために `app` イメージを含む成果物が必要です。直近のビルドが Web のみなら、`--artifact-dir` で元の完全な成果物を選ぶか、先に `pnpm build --target docker --images app` を実行します。このイメージは初期化に使い、稼働中の `app` サービスは更新しません。
|
|
60
82
|
|
|
61
|
-
|
|
83
|
+
#### マシン同士が接続できない場合:パッケージをコピー
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
pnpm run deploy --env prod --build --bundle-only --output release-prod.tar
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
版 1.2.3 なら release-prod-1.2.3.tar と隣接する -deploy/ を生成します。tar は選択アプリ・ミドルウェアのイメージ、設定、秘密の環境ファイル、チェックサム、README、apply.sh を含みます。Windows は deploy.ps1、Linux/macOS は deploy.sh でアップロードし、同じサーバー処理を実行します。別の PC・OS に移す場合、秘密鍵とサーバー指紋ファイルのパスを移動先に合わせます。Windows は deploy-target.json、Linux/macOS は HAI_DEPLOY_IDENTITY_FILE と HAI_DEPLOY_KNOWN_HOSTS_FILE で指定します。
|
|
90
|
+
|
|
91
|
+
隔離された Linux では独立ディレクトリに展開し、`sh apply.sh` を実行します。引数で配置先を上書きできます。各段階の失敗は非ゼロ終了し、イメージ導入・起動・HTTP 検査を別々に報告します。result-<配置ID>.json に結果を記録し、成功時だけ current を更新します。同じ配置 ID の再適用は停止しますが、同じアプリ版から生成した新しい配布物は適用できます。更新失敗時は対象コンテナーと設定を以前の状態に戻すことを試み、データボリュームと診断情報を保持します。すでに書き込まれた業務データは元に戻しません。
|
|
92
|
+
|
|
93
|
+
#### 完全オフラインの前に確認する
|
|
94
|
+
|
|
95
|
+
完全 tar は自前ミドルウェアのアーカイブと一致するアーキテクチャを含み、起動時にレジストリーへ接続しません。Linux に Docker/Podman、Docker Compose v2 または podman-compose 1.6.0 以降、sh、tar、sha256sum、awk、curl、ディレクトリ・コンテナー権限が必要です。秘密設定を安全に転送し、版間でボリューム識別を保持します。外部ネットワークを切って起動、ログイン、再読込、再起動と永続化を検証します。HTTPS、証明書、DNS、外部サービスは別途用意します。
|
|
96
|
+
|
|
97
|
+
### SDK
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import { deploy } from '@h-ai/deploy'
|
|
101
|
+
|
|
102
|
+
const initialized = await deploy.init({ provider: { type: 'docker-ssh', expose: { hostPort: 18080 } } })
|
|
103
|
+
if (!initialized.success)
|
|
104
|
+
throw new Error(initialized.error.message)
|
|
105
|
+
try {
|
|
106
|
+
const result = await deploy.deployApp('./packages/demo-serv', {
|
|
107
|
+
environment: 'prod',
|
|
108
|
+
envDir: '.',
|
|
109
|
+
bundleOnly: true,
|
|
110
|
+
artifactDir: './.hai/build/docker/<buildId>',
|
|
111
|
+
runtime: 'auto',
|
|
112
|
+
})
|
|
113
|
+
if (!result.success)
|
|
114
|
+
throw new Error(result.error.message)
|
|
115
|
+
// result.data.bundlePath / instructions; packaged does not mean server ready.
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
await deploy.close()
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`selectedServices: ['web']` は部分更新を選択し、`onProgress` はパッケージ作成とサーバー実行の段階を通知します。`deploy.scan` と `deploy.credentials.*` は初期化前も使用できます。HaiResult.success を確認してからデータを読み取ります。Vercel は既存 .vercel/output を prebuilt API でアップロードするためネット接続が必要で、オフラインや Compose の部分公開には対応しません。
|
|
123
|
+
|
|
124
|
+
## 開発とテスト
|
|
62
125
|
|
|
63
126
|
```sh
|
|
64
127
|
pnpm --filter @h-ai/deploy typecheck
|
|
65
128
|
pnpm --filter @h-ai/deploy lint
|
|
66
129
|
pnpm --filter @h-ai/deploy build
|
|
67
130
|
pnpm --filter @h-ai/deploy test
|
|
68
|
-
pnpm --filter @h-ai/cli test
|
|
69
131
|
pnpm --filter @h-ai/cli test:scaffold-gates
|
|
70
132
|
pnpm --filter @h-ai/cli test:deploy-gates
|
|
71
133
|
```
|
|
72
134
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
デプロイのゲートは既定でホストのプロキシを転送しません。依存のダウンロードに必要な場合、テスト専用 `HAI_DEPLOY_E2E_CONTAINER_PROXY`(既定は未設定)を設定します。Windows Podman の PowerShell の例は `$env:HAI_DEPLOY_E2E_CONTAINER_PROXY='http://host.containers.internal:10808'` です。ビルドコンテナーから到達できるアドレスを使い、アプリ設定や配布イメージには保存しません。
|
|
135
|
+
実際の生成プロジェクト、SSH と手動公開を検証します。レジストリー接続禁止、部分更新、破損アーカイブ、同一版での再公開、ヘルスチェック失敗を含めます。finally/teardown ではテスト自身が作成したプロジェクト、イメージ、コンテナー、ログ、プロセスのみを削除します。
|
|
76
136
|
|
|
77
|
-
|
|
137
|
+
## ライセンス
|
|
78
138
|
|
|
79
|
-
|
|
139
|
+
Apache-2.0
|