phala 1.1.8 → 1.1.10

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 CHANGED
@@ -1,838 +1,145 @@
1
- <h1 align="center">Phala Cloud CLI</h1>
2
- <p align="center">
3
- <b>Secure. Confidential. Verifiable.</b>
4
- </p>
5
-
6
- A command-line tool for managing Trusted Execution Environment (TEE) deployments on Phala Cloud, from local development to cloud deployment.
7
- ___
8
-
9
- <p align="center">
10
- <b>👥 Community & Support</b>
11
-
12
- <div align="center">
13
-
14
- [Phala Network Discord](https://discord.gg/phala-network) | [GitHub Issues](https://github.com/Phala-Network/phala-cloud-cli/issues) | [Phala Documentation](https://docs.phala.network)
15
-
16
- </div>
17
- </p>
18
-
19
- ## Usage
20
-
21
- - [Dstack-TEE: Dstack](https://github.com/Dstack-TEE/dstack)
22
- - Bun for runtime and package management
23
- - TypeScript for type safety
24
- - Commander.js for CLI interface
25
- - Zod for runtime validation
26
-
27
- ## 🚀 Quick Start (5 Minutes)
28
-
29
- 1. **Install Prerequisites**:
30
- ```bash
31
- # Install Bun
32
- curl -fsSL https://bun.sh/install | bash
33
-
34
- # Verify Docker is installed
35
- docker --version
36
- ```
37
-
38
- 2. **Install TEE Cloud CLI**:
39
-
40
- Install via npm or use npx/bunx
41
- ```bash
42
- # Install the CLI globally
43
- npm install -g phala
44
- ```
45
-
46
- > **NOTE**
47
- >
48
- > You can use `npx` or `bunx` to call the `phala` command
49
- >
50
- > ```bash
51
- > # Use npx/bunx
52
- >
53
- > npx phala help
54
- > bunx phala help
55
- > ```
56
-
57
- ```bash
58
- # Phala CLI help menu
59
- npx phala help
60
- ```
61
-
62
- 3. **Sign Up and Get API Key**:
63
-
64
- To deploy applications to Phala Cloud, you'll need an API key:
65
-
66
- - Visit [Phala Cloud](https://cloud.phala.com/login) to log into your Phala Cloud account. If you do not have an account, registe [here](https://cloud.phala.com/register?invite=beta).
67
- - After logging in, navigate to the "API Keys" section in your profile
68
- - Create a new API key with an appropriate name (e.g., "CLI Access")
69
- - Copy the generated API key - you'll need it for authentication
70
- - You can verify your API key using:
71
- ```bash
72
- phala auth login [your-phala-cloud-api-key]
73
- phala auth status
74
- ```
75
-
76
- 4. **Deploy Your First Confidential App**:
77
- Clone the [Dstack Examples](https://github.com/Dstack-TEE/dstack-examples) repo and cd into the webshell directory
78
- ```bash
79
- git clone https://github.com/Dstack-TEE/dstack-examples.git && cd dstack-examples/webshell
80
- ```
81
-
82
- ```bash
83
- # Deploy the webshell Dstack example
84
- phala cvms create
85
- ```
86
-
87
- Provide a name and select from the drop down of examples
88
-
89
- ```bash
90
- # ? Enter a name for the CVM: webshell
91
- # ℹ Detected docker compose file: ./docker-compose.yml
92
-
93
- # ? Enter the path to your Docker Compose file:(docker-compose.yml)
94
- # ✔ Enter number of vCPUs (default: 1): 1
95
-
96
- # ✔ Enter memory in MB (default: 2048): 2048
97
- # ✔ Enter disk size in GB (default: 20): 20
98
- # ⟳ Fetching available TEEPods... ✓
99
- # ⟳ Getting public key from CVM... ✓
100
- # ⟳ Encrypting environment variables... ✓
101
- # ⟳ Creating CVM... ✓
102
- # ✓ CVM created successfully
103
- # ℹ CVM ID: 2755
104
- # ℹ Name: webshell
105
- # ℹ Status: creating
106
- # ℹ App ID: e15c1a29a9dfb522da528464a8d5ce40ac28039f
107
- # ℹ App URL: <https://cloud.phala.com/dashboard/cvms/app_e15c1a29a9dfb522da528464a8d5ce40ac28039f>
108
- # ℹ
109
- # ℹ Your CVM is being created. You can check its status with:
110
- # ℹ phala cvms status e15c1a29a9dfb522da528464a8d5ce40ac28039f
111
- ```
112
-
113
- Now interact with your application in Phala Cloud by going to the url on port 7681 (Example of what a url at port 7681 would look like https://e15c1a29a9dfb522da528464a8d5ce40ac28039f-7681.dstack-prod5.phala.network)
114
-
115
- 5. **Check the CVM's Attestation**:
116
- ```bash
117
- phala cvms attestation
118
-
119
- # ℹ No CVM specified, fetching available CVMs...
120
- # ⟳ Fetching available CVMs... ✓
121
- # ✔ Select a CVM: testing (88721d1685bcd57166a8cbe957cd16f733b3da34) - Status: running
122
- # ℹ Fetching attestation information for CVM 88721d1685bcd57166a8cbe957cd16f733b3da34...
123
- # ⟳ Fetching attestation information... ✓
124
- # ✓ Attestation Summary:
125
-
126
- # or list the app-id
127
- phala cvms attestation 88721d1685bcd57166a8cbe957cd16f733b3da34
128
- ```
129
-
130
-
131
- ## 🏗️ Development Workflow
132
-
133
- ### 1️⃣ Local Development
134
-
135
- Develop and test your application locally with the built-in TEE simulator:
1
+ # Phala Cloud CLI
136
2
 
137
- ```bash
138
- # Start the TEE simulator
139
- phala simulator start
140
-
141
- # Build your Docker image
142
- phala docker build --image my-tee-app --tag v1.0.0
143
-
144
- # Create an environment file
145
- echo "API_KEY=test-key" > .env
146
- echo "DEBUG=true" >> .env
147
- ```
148
-
149
- ### 2️⃣ Cloud Deployment
150
-
151
- Deploy your application to Phala's decentralized TEE Cloud:
152
-
153
- ```bash
154
- # Set your Phala Cloud API key
155
- phala auth login
156
-
157
- # Login to Docker and Push your image to Docker Hub
158
- phala docker login
159
- phala docker build --image my-tee-app --tag v1.0.0
160
- phala docker push --image my-tee-app --tag v1.0.0
161
-
162
- # Deploy to Phala Cloud
163
- phala cvms create --name my-tee-app --compose ./docker-compose.yml --env-file ./.env
164
-
165
- # Access your app via the provided URL
166
- ```
167
-
168
- ## 💼 Real-World Use Cases for Confidential Computing
169
-
170
- ### 🏦 Financial Services
171
- - **Private Trading Algorithms**: Execute proprietary trading strategies without revealing algorithms
172
- - **Secure Multi-Party Computation**: Perform financial calculations across organizations without exposing sensitive data
173
- - **Compliant Data Processing**: Process regulated financial data with provable security guarantees
174
-
175
- ### 🏥 Healthcare
176
- - **Medical Research**: Analyze sensitive patient data while preserving privacy
177
- - **Drug Discovery**: Collaborate on pharmaceutical research without exposing intellectual property
178
- - **Health Record Processing**: Process electronic health records with HIPAA-compliant confidentiality
179
-
180
- ### 🔐 Cybersecurity
181
- - **Secure Key Management**: Generate and store cryptographic keys in hardware-protected environments
182
- - **Threat Intelligence Sharing**: Share cyber threat data across organizations without exposing sensitive details
183
- - **Password Verification**: Perform credential validation without exposing password databases
184
-
185
- ### 🏢 Enterprise Applications
186
- - **Confidential Analytics**: Process sensitive business data without exposure to cloud providers
187
- - **IP Protection**: Run proprietary algorithms and software while preventing reverse engineering
188
- - **Secure Supply Chain**: Validate and process sensitive supply chain data across multiple organizations
189
-
190
- ### 🌐 Web3 and Blockchain
191
- - **Private Smart Contracts**: Execute contracts with confidential logic and data
192
- - **Decentralized Identity**: Process identity verification without exposing personal information
193
- - **Trustless Oracles**: Provide verified external data to blockchain applications
194
-
195
- ## 🧩 Project Structure
196
-
197
- The Phala Cloud CLI is organized around core workflows:
198
-
199
- 1. **Authentication**: Connect to your Phala Cloud account
200
- 2. **TEEPod Info**: Fetch information about TEEPods (TEEPods are where your docker apps deploy to)
201
- 3. **Docker Management**: Build and manage Docker images for TEE
202
- 4. **TEE Simulation**: Local development environment
203
- 5. **Cloud Deployment**: Deploy to production and manage TEE Cloud deployments
204
-
205
- ## 📚 Command Reference
206
-
207
- The Phala Cloud CLI provides a comprehensive set of commands for managing your TEE deployments. Below is a detailed reference for each command category.
208
-
209
- ### Authentication Commands
210
-
211
- Commands for managing authentication with the Phala Cloud API.
212
-
213
- #### Login
214
-
215
- ```bash
216
- phala auth login [options]
217
- ```
218
-
219
- Set the API key for authentication with Phala Cloud. The API key is stored with encryption for enhanced security.
220
-
221
- **Options:**
222
-
223
- - `[api-key]`: Phala Cloud API key to set
224
-
225
- **Example:**
226
- ```bash
227
- phala auth login [your-phala-cloud-api-key]
228
- ```
229
-
230
- #### Logout
231
-
232
- ```bash
233
- phala auth logout
234
- ```
235
-
236
- Remove the stored API key.
237
-
238
- **Example:**
239
- ```bash
240
- phala auth logout
241
- ```
242
-
243
- #### Status
244
-
245
- ```bash
246
- phala status [options]
247
- ```
248
-
249
- Check your authentication status with Phala Cloud. Displays user information including API endpoint, username, and current workspace.
250
-
251
- > **Note**: `phala auth status` is still available for backward compatibility, but it's recommended to use `phala status` instead.
252
-
253
- **Options:**
254
- - `-j, --json`: Output in JSON format
255
- - `-d, --debug`: Enable debug output
256
-
257
- **Example:**
258
- ```bash
259
- phala status
260
- phala status --json
261
- ```
262
-
263
- #### Environment Variable Override
264
-
265
- You can override the stored API key using the `PHALA_CLOUD_API_KEY` environment variable. This is useful for CI/CD workflows or testing with different accounts.
266
-
267
- **Example:**
268
- ```bash
269
- # Temporarily use a different API key
270
- PHALA_CLOUD_API_KEY="phak_your_api_key_here" phala cvms list
271
-
272
- # In CI/CD pipelines
273
- export PHALA_CLOUD_API_KEY="phak_your_api_key_here"
274
- phala deploy --name my-app
275
- ```
276
-
277
- You can also override the API endpoint using the `PHALA_CLOUD_API_PREFIX` environment variable.
278
-
279
- **Example:**
280
- ```bash
281
- PHALA_CLOUD_API_PREFIX="https://cloud-api.phala.ai" phala cvms list
282
- ```
283
-
284
- #### JSON Output Mode
285
-
286
- All commands support the `--json` flag for machine-readable output, useful for automation and CI/CD pipelines.
287
-
288
- **Example:**
289
- ```bash
290
- # Get CVM list as JSON
291
- phala cvms list --json
292
-
293
- # Parse with jq
294
- phala status --json | jq '.username'
295
- ```
296
-
297
- ### Docker Management Commands
298
-
299
- Commands for managing Docker images for TEE deployments.
300
-
301
- #### Docker Login
302
-
303
- ```bash
304
- phala docker login [options]
305
- ```
306
-
307
- Login to Docker Hub to enable pushing and pulling images.
308
-
309
- **Options:**
310
-
311
- - `-u, --username <username>`: Docker Hub username (if not provided, you will be prompted)
312
- - `-p, --password <password>`: Docker Hub password (if not provided, you will be prompted)
313
- - `-r, --registry <registry>`: Docker registry URL (optional, defaults to Docker Hub)
314
-
315
- **Example:**
316
- ```bash
317
- phala docker login --username your-dockerhub-username
318
- ```
319
-
320
- #### Build Docker Image
321
-
322
- ```bash
323
- phala docker build [options]
324
- ```
325
-
326
- Build a Docker image for your TEE application.
327
-
328
- **Options:**
329
- - `-i, --image <image>`: Image name (required)
330
- - `-t, --tag <tag>`: Image tag (required)
331
- - `-f, --file <file>`: Path to Dockerfile (defaults to 'Dockerfile')
332
-
333
- **Example:**
334
- ```bash
335
- phala docker build --image my-tee-app --tag v1.0.0 --file ./Dockerfile
336
- ```
337
-
338
- #### Push Docker Image
339
-
340
- ```bash
341
- phala docker push [options]
342
- ```
343
-
344
- Push a Docker image to Docker Hub.
345
-
346
- **Options:**
347
- - `-i, --image <image>`: Image name (required)
348
- - `-t, --tag <tag>`: Image tag (required)
349
-
350
- **Example:**
351
- ```bash
352
- phala docker push --image my-tee-app --tag v1.0.0
353
- ```
354
-
355
- #### Build Docker Compose File
356
-
357
- ```bash
358
- phala docker generate [options]
359
- ```
360
-
361
- Build a Docker Compose file for your TEE application.
362
-
363
- **Options:**
364
- - -i, --image <image> Docker image name to use in the compose file
365
- - -t, --tag <tag> Docker image tag to use in the compose file
366
- - -e, --env-file <envFile> Path to environment variables file
367
- - -o, --output <output> Output path for generated docker-compose.yml
368
- - --template <template> Template to use for the generated docker-compose.yml
369
- - --manual Skip automatic image detection and enter image/tag manually
370
- - -h, --help display help for command
371
-
372
- **Example:**
373
- ```bash
374
- phala docker generate --image my-tee-app --tag v1.0.0 --env-file ./.env
375
- ```
376
-
377
- ### TEE Simulator Commands
378
-
379
- Commands for managing the local TEE simulator for development and testing. When run without subcommands, shows the current status of the simulator.
380
-
381
- #### Check Status
382
-
383
- ```bash
384
- phala simulator
385
- ```
386
-
387
- Shows the current status of the TEE simulator, including the process ID and endpoint information if running.
388
-
389
- #### Start Simulator
390
-
391
- ```bash
392
- phala simulator start [options]
393
- ```
394
-
395
- Start the TEE simulator locally for development and testing.
396
-
397
- **Options:**
398
-
399
- - `-p, --port <port>`: Port to bind the simulator to (default: 8000)
400
- - `-v, --verbose`: Enable verbose output
401
-
402
- **Examples:**
403
-
404
- ```bash
405
- # Start with default options
406
- phala simulator start
407
-
408
- # Start with verbose output
409
- phala simulator start --verbose
410
- ```
411
-
412
- #### Stop Simulator
413
-
414
- ```bash
415
- phala simulator stop
416
- ```
417
-
418
- Stop the running TEE simulator.
419
-
420
- **Example:**
421
-
422
- ```bash
423
- phala simulator stop
424
- ```
425
-
426
- #### Environment Variables
427
-
428
- When the simulator is running, you'll need to set these environment variables to use it:
429
-
430
- ```bash
431
- export DSTACK_SIMULATOR_ENDPOINT=/path/to/dstack.sock
432
- export TAPPD_SIMULATOR_ENDPOINT=/path/to/tappd.sock
433
- ```
434
-
435
- These variables will be automatically displayed when you run `phala simulator` while the simulator is running.
436
-
437
- ### Cloud Virtual Machine (CVM) Commands
438
-
439
- Commands for managing Cloud Virtual Machines (CVMs) on Phala Cloud.
440
-
441
- #### List CVMs
442
-
443
- List all your CVMs:
444
-
445
- ```bash
446
- phala cvms list
447
- ```
448
-
449
- #### Manage TEE Nodes
450
-
451
- List all available worker nodes to find TEEPod IDs for replication. You can use any of these commands to list nodes:
452
-
453
- ```bash
454
- # List all available nodes (recommended)
455
- phala nodes
456
-
457
- # Alternative ways to list nodes
458
- phala nodes list
459
- phala nodes ls
460
- ```
461
-
462
- This will show you all available TEEPod nodes along with their IDs, which you can use with the `replicate` command's `--teepod-id` option. The output includes node details such as ID, name, region, FMSPC, device ID, and available images.
463
-
464
- #### Get CVM Details
465
-
466
- ```bash
467
- phala cvms get [options] <app-id>
468
- ```
469
-
470
- Get detailed information about a specific CVM.
471
-
472
- **Arguments:**
473
- - `app-id`: App ID of the CVM
3
+ Command-line tool for deploying and managing TEE (Trusted Execution Environment) applications on [Phala Cloud](https://cloud.phala.com).
474
4
 
475
- **Options:**
476
- - `-j, --json`: Output in JSON format
5
+ ## Install
477
6
 
478
- **Example:**
479
7
  ```bash
480
- phala cvms get app_123456
8
+ npm install -g phala
481
9
  ```
482
10
 
483
- #### Deploy (Simplified)
11
+ Or run directly without installing:
484
12
 
485
13
  ```bash
486
- phala deploy [options]
14
+ npx phala <command>
15
+ bunx phala <command>
487
16
  ```
488
17
 
489
- Deploy a new CVM or update an existing one. Creates a new CVM by default. If `--cvm-id` is provided or a CVM ID is configured in `phala.toml`, updates the existing CVM instead.
490
-
491
- **Key Features:**
492
- - **Auto Resource Matching**: Backend automatically finds the best available node based on your requirements
493
- - **All Parameters Optional**: Specify only what you need; the system handles the rest
494
- - **Structured Error Messages**: Clear error codes (ERR-xxxx) with actionable suggestions
495
- - **On-chain KMS Support**: Built-in support for decentralized key management
496
-
497
- **Options:**
498
- - `-n, --name <name>`: Name of the CVM (auto-generated from folder name if not provided)
499
- - `-c, --compose <compose>`: Path to Docker Compose file (default: docker-compose.yml)
500
- - `-t, --instance-type <type>`: Instance type (e.g., tdx.small, tdx.medium, tdx.large) - **optional**, auto-selected if not specified
501
- - `-r, --region <region>`: Preferred region (e.g., us-west, eu-central) - **optional**, auto-selected if not specified
502
- - `--vcpu <vcpu>`: Number of vCPUs - **optional**, auto-matched if not specified
503
- - `--memory <memory>`: Memory with unit (e.g., 2G, 1024MB) - **optional**, auto-matched if not specified
504
- - `--disk-size <diskSize>`: Disk size with unit (e.g., 50G, 100GB) - **optional**, auto-matched if not specified
505
- - `--image <image>`: OS image version - **optional**, auto-selected if not specified
506
- - `--node-id <nodeId>`: Specific node ID - **optional**, auto-selected if not specified
507
- - `-e, --env-file <envFile>`: Path to environment variables file
508
- - `-i, --interactive`: Enable interactive mode for required parameters
509
- - `--kms-id <kmsId>`: KMS ID for on-chain key management
510
- - `--private-key <key>`: Private key for on-chain KMS deployment
511
- - `--rpc-url <url>`: RPC URL for blockchain interaction
512
- - `--uuid <uuid>`: UUID of existing CVM to upgrade
513
- - `--wait`: Wait for deployment/update to complete before returning
514
- - `-j, --json`: Output in JSON format
515
- - `-d, --debug`: Enable debug logging
516
-
517
- **Examples:**
18
+ ## Quick Start
518
19
 
519
20
  ```bash
520
- # --- New Deployment ---
21
+ # Authenticate (opens browser for device flow)
22
+ phala login
521
23
 
522
- # Simplest - auto-select everything
24
+ # Deploy from a directory with docker-compose.yml
523
25
  phala deploy
524
26
 
525
- # Specify instance type and region
526
- phala deploy --instance-type tdx.medium --region us-west
27
+ # Link the directory to the CVM for future commands
28
+ phala link
527
29
 
528
- # With environment file
529
- phala deploy -e .env
30
+ # View container logs
31
+ phala logs
530
32
 
531
- # With on-chain KMS
532
- phala deploy --kms-id ethereum --private-key <key> --rpc-url <url>
533
-
534
- # Interactive mode for guided setup
535
- phala deploy --interactive
536
-
537
- # --- Update Existing CVM ---
538
-
539
- # Update by CVM ID (app_id, UUID, or name)
540
- phala deploy --cvm-id app_abc123
541
-
542
- # Update with new compose file and environment variables
543
- phala deploy --cvm-id my-app --compose ./new-docker-compose.yml -e .env
544
-
545
- # Update and wait for completion
546
- phala deploy --cvm-id app_abc123 --wait
547
-
548
- # If phala.toml has cvm_id configured, just run deploy to update
549
- phala deploy
33
+ # SSH into the CVM
34
+ phala ssh
550
35
  ```
551
36
 
552
- **Error Handling:**
553
-
554
- The deploy command provides structured error messages with unique error codes for easy troubleshooting:
37
+ > **Tip:** Run `phala link` after your first deploy. It creates a `phala.toml` that binds the directory to the CVM, so subsequent commands (`deploy`, `logs`, `ssh`, `cp`, `ps`) work without specifying a CVM ID. `phala.toml` is safe to commit to version control.
555
38
 
556
- ```
557
- Error [ERR-1003]: The selected node does not have enough CPU capacity
558
-
559
- Details:
560
- - Need 4 CPUs, but only 2 are available
561
- - node_id: 6
39
+ ## Commands
562
40
 
563
- Suggestions:
564
- - Choose a smaller instance type
565
- - Reduce the number of CPUs requested
566
- - Remove the --node-id flag to search all available nodes
41
+ ### Deploy
567
42
 
568
- Need help? Contact support: https://cloud.phala.com/contact
569
- Reference error code: ERR-1003
570
- ```
43
+ | Command | Description |
44
+ |---------|-------------|
45
+ | [`deploy`](docs/deploy.md) | Deploy new CVM or update existing one |
46
+ | [`instance-types`](docs/instance-types.md) | List available instance types |
47
+ | [`nodes`](docs/nodes.md) | List TEE worker nodes |
571
48
 
572
- Common error codes:
573
- - `ERR-1001`: Instance type not found
574
- - `ERR-1002`: No available resources match requirements
575
- - `ERR-1003`: Insufficient CPU capacity
576
- - `ERR-1004`: Insufficient memory
577
- - `ERR-2003`: OS image not available
578
- - `ERR-2005`: Node not accessible
49
+ ### Manage
579
50
 
580
- For a complete list of error codes, refer to the error code documentation.
51
+ | Command | Description |
52
+ |---------|-------------|
53
+ | [`apps`](docs/apps.md) | List deployed CVMs |
54
+ | [`cvms`](docs/cvms.md) | Manage CVMs (start, stop, restart, delete, resize, ...) |
55
+ | [`link`](docs/link.md) | Link a local directory to a CVM |
56
+ | [`simulator`](docs/simulator.md) | Local TEE simulator for development |
581
57
 
582
- #### Create CVM
58
+ ### CVM Operations
583
59
 
584
- ```bash
585
- phala cvms create [options]
586
- ```
60
+ | Command | Description |
61
+ |---------|-------------|
62
+ | [`logs`](docs/logs.md) | Fetch logs from a CVM (container, serial, stdout/stderr) |
63
+ | [`ps`](docs/ps.md) | List containers of a CVM |
64
+ | [`ssh`](docs/ssh.md) | Connect to a CVM via SSH |
65
+ | [`cp`](docs/cp.md) | Copy files to/from a CVM via SCP |
587
66
 
588
- Create a new CVM on Phala Cloud.
589
-
590
- **Options:**
591
- - `-n, --name <name>`: Name of the CVM (required)
592
- - `-c, --compose <compose>`: Path to Docker Compose file (required)
593
- - `--vcpu <vcpu>`: Number of vCPUs (default: 1)
594
- - `--memory <memory>`: Memory in MB (default: 2048)
595
- - `--disk-size <diskSize>`: Disk size in GB (default: 20)
596
- - `--teepod-id <teepodId>`: TEEPod ID to launch the CVM to (default: 3)
597
- - `--image <image>`: Version of dstack image to use (i.e. dstack-0.3.5)
598
- - `-e, --env-file <envFile>`: Environment variables in the form of KEY=VALUE
599
- - `--skip-env`: Path to environment file (default: false)
600
- - `--debug`: Enable debug mode
601
-
602
- **Example:**
603
- ```bash
604
- phala cvms create --name my-tee-app --compose ./docker-compose.yml --vcpu 2 --memory 4096 --diskSize 60 --teepod-id 3 --image dstack-dev-0.3.5 --env-file ./.env
605
- ```
67
+ ### Profile / Auth
606
68
 
607
- ##### Using a Private Docker Registry
69
+ | Command | Description |
70
+ |---------|-------------|
71
+ | [`login`](docs/login.md) | Authenticate with Phala Cloud |
72
+ | [`logout`](docs/logout.md) | Remove stored API key |
73
+ | [`status`](docs/status.md) | Check authentication status |
74
+ | [`whoami`](docs/whoami.md) | Print the current user |
75
+ | [`profiles`](docs/profiles.md) | List auth profiles |
76
+ | [`switch`](docs/switch.md) | Switch auth profiles |
608
77
 
609
- You can deploy images from a private Docker registry by setting the appropriate environment variables. Check the [docs](https://docs.phala.network/phala-cloud/create-cvm/create-with-private-docker-image#deploy-private-docker-image-with-cli) for more information.
78
+ ### Advanced
610
79
 
611
- ##### 🔐 DockerHub:
612
- Set these variables:
613
- - `DSTACK_DOCKER_USERNAME` Your DockerHub username *(required)*
614
- - `DSTACK_DOCKER_PASSWORD` Your DockerHub password or personal access token *(required)*
615
- - `DSTACK_DOCKER_REGISTRY` Registry URL (optional, defaults to DockerHub)
80
+ | Command | Description |
81
+ |---------|-------------|
82
+ | [`api`](docs/api.md) | Make authenticated API requests |
83
+ | [`self`](docs/self.md) | CLI self-management (update) |
84
+ | [`completion`](docs/completion.md) | Generate shell completion scripts |
616
85
 
617
- ##### 🔐 AWS ECR:
618
- Set these variables:
619
- - `DSTACK_AWS_ACCESS_KEY_ID` – AWS access key *(required)*
620
- - `DSTACK_AWS_SECRET_ACCESS_KEY` – AWS secret key *(required)*
621
- - `DSTACK_AWS_REGION` – AWS region of the ECR *(required)*
622
- - `DSTACK_AWS_ECR_REGISTRY` – Full ECR registry URL *(required)*
86
+ ## Configuration
623
87
 
624
- Once set, the CLI will automatically authenticate and pull your private image securely.
88
+ ### Project file (`phala.toml`)
625
89
 
626
- #### Upgrade CVM
90
+ Place a `phala.toml` in your project root to bind a directory to a CVM:
627
91
 
628
- ```bash
629
- phala cvms upgrade [options] <app-id>
92
+ ```toml
93
+ app_id = "app_abc123"
94
+ compose_file = "docker-compose.yml"
95
+ env_file = ".env"
96
+ public_logs = true
97
+ listed = false
630
98
  ```
631
99
 
632
- Upgrade a CVM to a new version.
100
+ When `phala.toml` exists, commands like `deploy`, `logs`, `ssh`, and `cp` automatically use the configured CVM.
633
101
 
634
- **Arguments:**
635
- - `app-id`: App ID of the CVM to upgrade
102
+ ### Environment variables
636
103
 
637
- **Options:**
638
- - `-c, --compose <compose>`: Path to new Docker Compose file
639
- - `--env-file <envFile>`: Path to environment file
640
- - `--debug`: Enable debug mode
104
+ | Variable | Description |
105
+ |----------|-------------|
106
+ | `PHALA_CLOUD_API_KEY` | Override the stored API key |
107
+ | `PHALA_CLOUD_API_PREFIX` | Override the API base URL |
108
+ | `PHALA_CLOUD_DIR` | Override the credentials directory (default: `~/.phala-cloud`) |
109
+ | `PHALA_UPDATE_CHANNEL` | Release channel for `self update` (e.g., `latest`, `beta`) |
641
110
 
642
- **Example:**
643
- ```bash
644
- phala cvms upgrade app_123456 --compose ./new-docker-compose.yml --env-file ./.env
645
- ```
646
-
647
- #### Start CVM
648
-
649
- ```bash
650
- phala cvms start [app-id]
651
- ```
111
+ ### Profiles
652
112
 
653
- Start a stopped CVM.
113
+ Manage multiple workspaces with named profiles:
654
114
 
655
- **Arguments:**
656
- - `app-id`: App ID of the CVM to start
657
-
658
- **Example:**
659
115
  ```bash
660
- phala cvms start e15c1a29a9dfb522da528464a8d5ce40ac28039f
116
+ phala login --profile work
117
+ phala login --profile personal
118
+ phala switch work
119
+ phala profiles
661
120
  ```
662
121
 
663
- #### Stop CVM
664
-
665
- ```bash
666
- phala cvms stop [app-id]
667
- ```
122
+ Credentials are stored in `~/.phala-cloud/` with restricted file permissions.
668
123
 
669
- Stop a running CVM.
124
+ ## Documentation
670
125
 
671
- **Arguments:**
672
- - `app-id`: App ID of the CVM to stop
126
+ Full command reference with all options, arguments, and examples:
673
127
 
674
- **Example:**
675
- ```bash
676
- phala cvms stop e15c1a29a9dfb522da528464a8d5ce40ac28039f
677
- ```
128
+ https://github.com/Phala-Network/phala-cloud/tree/main/cli/docs
678
129
 
679
- #### Restart CVM
130
+ ## Development
680
131
 
681
132
  ```bash
682
- phala cvms restart [app-id]
683
- ```
684
-
685
- Restart a CVM.
133
+ bun install
134
+ bun run src/index.ts <command>
686
135
 
687
- **Arguments:**
688
- - `app-id`: App ID of the CVM to restart
689
-
690
- **Example:**
691
- ```bash
692
- phala cvms restart e15c1a29a9dfb522da528464a8d5ce40ac28039f
136
+ # Quality checks
137
+ bun run fmt # Format with Biome
138
+ bun run lint # Lint with Biome
139
+ bun run type-check # TypeScript type checking
140
+ bun run test # Run tests
693
141
  ```
694
142
 
695
- #### Replicate App
143
+ ## License
696
144
 
697
- ```bash
698
- phala cvms replicate [options] <cvm-uuid>
699
- ```
700
-
701
- Create a replica of an existing App using cvm-uuid. Before replicating, you can use `phala nodes` to find available TEEPod IDs.
702
-
703
- **Basic Usage:**
704
- ```bash
705
- phala cvms replicate <cvm-uuid>
706
- ```
707
-
708
- **Options:**
709
- - `--teepod-id <teepodId>`: TEEPod ID to use for the replica (use `phala nodes` to find available TEEPod IDs)
710
- - `-e, --env-file <envFile>`: Path to environment file for the replica (will be encrypted with the original CVM's public key)
711
-
712
- **Example Workflow:**
713
- ```bash
714
- # List available nodes to find a teepod-id
715
- phala nodes
716
-
717
- # Create a replica using a specific teepod-id
718
- phala cvms replicate <cvm-uuid> --teepod-id 123
719
-
720
- # With environment variables
721
- phala cvms replicate <cvm-uuid> -e .env
722
- ```
723
-
724
- **Example:**
725
- ```bash
726
- # Basic usage
727
- phala cvms replicate e15c1a29a9dfb522da528464a8d5ce40ac28039f
728
-
729
- # Specify a different TEEPod
730
- phala cvms replicate e15c1a29a9dfb522da528464a8d5ce40ac28039f --teepod-id 123
731
-
732
- # Use a different environment file
733
- phala cvms replicate e15c1a29a9dfb522da528464a8d5ce40ac28039f -e .env.new
734
- ```
735
-
736
- #### Delete CVM
737
-
738
- ```bash
739
- phala cvms delete [options] <app-id>
740
- ```
741
-
742
- Delete a CVM.
743
-
744
- **Arguments:**
745
- - `app-id`: App ID of the CVM to delete
746
-
747
- **Options:**
748
- - `-f, --force`: Skip confirmation prompt
749
-
750
- **Example:**
751
- ```bash
752
- phala cvms delete e15c1a29a9dfb522da528464a8d5ce40ac28039f
753
- phala cvms delete --force e15c1a29a9dfb522da528464a8d5ce40ac28039f
754
- ```
755
-
756
- ## 📋 Sample Applications
757
-
758
- Explore these example applications to understand different use cases for TEE deployment:
759
-
760
- - **[Timelock Encryption](./examples/timelock-nts/)**: Encrypt messages that can only be decrypted after a specified time
761
- - **[Light Client](./examples/lightclient/)**: A lightweight blockchain client implementation
762
- - **[SSH Over TEE Proxy](./examples/ssh-over-tproxy/)**: Secure SSH tunneling through a TEE
763
- - **[Web Shell](./examples/webshell/)**: Browser-based secure terminal
764
- - **[Custom Domain](./examples/custom-domain/)**: Deploy with your own domain name
765
- - **[Private Docker Image](./examples/private-docker-image-deployment/)**: Deploy using private Docker registries
766
-
767
- ## 🛠️ Advanced Features
768
-
769
- ### Docker Compose Templates
770
-
771
- > This feature is still being developed. Best to build your own docker-compose file for now.
772
-
773
- (WIP) Choose from docker compose file for your application:
774
-
775
- ```bash
776
- phala docker generate --image my-app --tag v1.0.0 --env
777
- ```
778
-
779
- ### Customizing Resource Allocation
780
-
781
- Resize specific resources for your existing CVM:
782
-
783
- ```bash
784
- phala cvms resize e15c1a29a9dfb522da528464a8d5ce40ac28039f --name resource-intensive-app --compose ./compose.yml \
785
- --vcpu 4 --memory 8192 --disk-size 50 -r true -y
786
- ```
787
-
788
- ### Environment Variables Management
789
-
790
- ```bash
791
- # Using env file
792
- phala cvms create --name env-app --compose ./compose.yml --env-file ./.env
793
- ```
794
-
795
-
796
- ## 🔒 Security
797
-
798
- The TEE Cloud CLI employs several security measures:
799
-
800
- 1. **Encrypted Credentials**: API keys and Docker credentials are stored with encryption using a machine-specific key
801
- 2. **Restricted Permissions**: All credential files are stored with 0600 permissions (user-only access)
802
- 3. **No Validation Storage**: API keys are not validated during login, preventing unnecessary transmission
803
- 4. **Local Storage**: All credentials are stored locally in the `~/.phala-cloud/` directory
804
-
805
- ## 🔍 Troubleshooting
806
-
807
- Common issues and solutions:
808
-
809
- 1. **Docker Build Fails**
810
- - Verify Docker daemon is running
811
- - Check Dockerfile path
812
- - Ensure proper permissions
813
-
814
- 2. **Simulator Issues**
815
- - Check if port 8090 is available
816
- - Verify Docker permissions
817
-
818
- 3. **Cloud Deployment Fails**
819
- - Validate API key
820
- - Confirm image exists on Docker Hub
821
- - Check environment variables
822
-
823
- For detailed help:
824
- ```bash
825
- phala --help
826
- phala <command> --help
827
- ```
828
-
829
- ## 📝 License
830
-
831
- Apache 2.0
832
-
833
- ## 🤝 Contributing
834
-
835
- To contribute or run in development mode:
836
- ```bash
837
- bun run src/index.ts
838
- ```
145
+ [Apache-2.0](LICENSE)