Skip to content

Commit d89b42e

Browse files
committed
[doc] Add app deployment section in deployment.md
1 parent 08cd5bb commit d89b42e

File tree

3 files changed

+72
-4
lines changed

3 files changed

+72
-4
lines changed

docs/assets/app-board.png

350 KB
Loading

docs/assets/app-deploy.png

152 KB
Loading

docs/deployment.md

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ port = 9300
4747
EOF
4848

4949
# Download Guest OS images
50-
wget "https://github.com/Dstack-TEE/meta-dstack/releases/download/v0.4.1/dstack-0.4.1.tar.gz"
50+
DSTACK_VERSION=0.4.2
51+
wget "https://github.com/Dstack-TEE/meta-dstack/releases/download/v${DSTACK_VERSION}/dstack-${DSTACK_VERSION}.tar.gz"
5152
mkdir -p images/
52-
tar -xvf dstack-0.4.1.tar.gz -C images/
53-
rm -f dstack-0.4.1.tar.gz
53+
tar -xvf dstack-${DSTACK_VERSION}.tar.gz -C images/
54+
rm -f dstack-${DSTACK_VERSION}.tar.gz
5455

5556
# run dstack-vmm
5657
./dstack-vmm -c vmm.toml
@@ -266,7 +267,7 @@ Similar to the KMS deployment, it will deploy the dstack-gateway CVM to the dsta
266267

267268
## Deploy dstack-vmm on other TDX hosts to serve user workloads
268269
After the KMS and dstack-gateway are deployed, you can deploy dstack-vmm on other TDX hosts to serve user workloads.
269-
270+
You can follow the steps at the beginning of this document to deploy dstack-vmm on other TDX hosts.
270271
Edit the vmm.toml file to set the KMS and dstack-gateway URLs.
271272

272273
```
@@ -275,3 +276,70 @@ Edit the vmm.toml file to set the KMS and dstack-gateway URLs.
275276
kms_urls = ["https://kms.test2.dstack.phala.network:9201"]
276277
gateway_urls = ["https://gateway.test2.dstack.phala.network:9202"]
277278
```
279+
280+
Then restart the dstack-vmm.
281+
282+
## Deploy app on the dstack-vmm
283+
284+
After the dstack-vmm is ready, you can deploy an app on it following the steps below.
285+
286+
### 1. On-chain Registration
287+
288+
The on-chain registration process includes two steps:
289+
290+
1. Deploy an App's control contract AppAuth. Developers can develop their own or choose the reference contract from the Dstack repository. Custom contracts need to implement the IAppAuth interface.
291+
2. Call KmsAuth.registerApp(appAuthAddress) to register and obtain the App Id
292+
293+
The Dstack repository provides scripts to complete these two steps:
294+
295+
```bash
296+
git clone https://github.com/Dstack-TEE/dstack
297+
cd dstack/kms/auth-eth
298+
npm install
299+
npx hardhat compile
300+
export PRIVATE_KEY=<your eth private key here>
301+
export KMS_CONTRACT_ADDRESS=0xFE6C45aE66344CAEF5E5D7e2cbD476286D651875
302+
npx hardhat app:deploy --allow-any-device --network phala
303+
```
304+
305+
Command output:
306+
```
307+
Deploying proxy...
308+
Waiting for deployment...
309+
AppAuth Proxy deployed to: 0xD4a546B1C7e63CD4CeD314b2C90108e49191A915
310+
Implementation deployed to: 0x5aC1671E1Df54994D023F0B05806821d6D84e086
311+
Deployment completed successfully
312+
Transaction hash: 0xceac2ac6d56a40fef903b947d3a05df42ccce66da7f356c5d54afda68277f9a9
313+
Waiting for transaction 0xe144e9007208079e5e82c04f727d2383c58184e74d4f860e62557b5f330ab832 to be confirmed...
314+
App registered in KMS successfully
315+
Registered AppId: 0xA35b434eE853fdf9c2Bf48Fa1583Ac1332d50255
316+
```
317+
318+
Note the AppId, which needs to be filled in when deploying cvm.
319+
320+
If you need to upgrade the contract in the future, please backup the `.openzeppelin/unknown-2035.json` file.
321+
322+
### 2. Add the App compose hash to the whitelist
323+
324+
Build app-compose.json and calculate its sha256 to get compose-hash. The compose hash can also be previewed in the dstack-vmm UI.
325+
326+
Call the hardhat command to add it to the whitelist (using AppAuth as an example here; custom AppAuth follows its own custom permission control logic).
327+
328+
```bash
329+
export PRIVATE_KEY=<your eth private key here>
330+
export KMS_CONTRACT_ADDRESS=0xFE6C45aE66344CAEF5E5D7e2cbD476286D651875
331+
npx hardhat app:add-hash --network phala --app-id 0xA35b434eE853fdf9c2Bf48Fa1583Ac1332d50255 0x44d9cb98aaa6ab11f5729fc7d6fd58117585e0e3fbec621612dcee6b2dfbcde5
332+
```
333+
334+
### 3. Deploy instances using dstack-vmm
335+
336+
![app deploy](assets/app-deploy.png)
337+
- Select image `dstack-0.4.2`
338+
- Fill in the AppId applied in the contract during deployment
339+
- Currently, test KmsAuth has set a whitelist for Base image, requiring instance memory to be `≥ 3G` or exactly `= 2G`
340+
341+
After the app starts normally, click [Board] to access.
342+
343+
You can see connections to two tproxy nodes:
344+
345+
![app board](assets/app-board.png)

0 commit comments

Comments
 (0)