> ## Documentation Index
> Fetch the complete documentation index at: https://phalanetwork.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Step 4 – Build and Run dstack components

> Build the dstack components, start the core services, and verify everything in the UI.

> **Heads-up:** This step assumes you finished **Step 3** (kernel headers, Rust, WireGuard, `.env`, and the `systemd` unit).

***

## 1 – Clone the Sources

```bash theme={null}
git clone https://github.com/Dstack-TEE/meta-dstack.git
cd meta-dstack
```

***

## 2 – Visual Walk-through

### 2.1 Connect to Your Server

| Action                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SSH into the host           | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step1.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=18162e9576d8392b72327afac5ee2d30" alt="" width="1594" height="1132" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step1.png" /><br />[step1.png](/docs/getting-started/first-deployment-steps/step-install-guide/step1.png)                   |
| Accept the fingerprint      | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step2.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=f3d700113199696f9295e0294932ba65" alt="" width="1304" height="164" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step2.png" /><br />[step2.png](/docs/getting-started/first-deployment-steps/step-install-guide/step2.png)                     |
| Confirm WireGuard installed | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step4.0.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=1d07b3ff9d43d727b2276d0ba78d2ed1" alt="" width="1186" height="372" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step4.0.png" /><br />[step4.0.png](/docs/getting-started/first-deployment-steps/step-install-guide/step4.0.png) |

***

### 2.2 Prepare the Build Environment

| Action                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Install Rust (rustup)       | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step4.1.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=7d1e712daaf0ba01e5749c76253db722" alt="" width="1206" height="372" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step4.1.png" /><br />[step4.1.png](/docs/getting-started/first-deployment-steps/step-install-guide/step4.1.png)   |
| Finish rustup setup         | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step4.2.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=781e1653492bd29ea8a0961ee68d6541" alt="" width="1278" height="814" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step4.2.png" /><br />[step4.2.png](/docs/getting-started/first-deployment-steps/step-install-guide/step4.2.png)   |
| Clone **meta-dstack**       | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step4.3.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=90131eec5c4dd1b085b0d6391aaa09e9" alt="" width="1120" height="1060" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step4.3.png" /><br />[step4.3.png](/docs/getting-started/first-deployment-steps/step-install-guide/step4.3.png) |
| Generate local build config | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step4.4.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=075c01f2a8d2e2f9895099c4590269d3" alt="" width="1516" height="468" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step4.4.png" /><br />[step4.4.png](/docs/getting-started/first-deployment-steps/step-install-guide/step4.4.png)   |

***

### 2.3 Build dstack Binaries

Inside the repo:

```bash theme={null}
./build.sh hostcfg          # host configuration
./build.sh dl <domain>      # gateway helper
./build.sh guest            # guest agent
```

| Command              |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `./build.sh hostcfg` | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step5.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=f0580d1090745ef520d68846a2513763" alt="" width="1606" height="434" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step5.png" /><br />[step5.png](/docs/getting-started/first-deployment-steps/step-install-guide/step5.png) |
| `./build.sh dl …`    | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step6.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=e391d3e6690fd85d95de357846cd687b" alt="" width="1236" height="438" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step6.png" /><br />[step6.png](/docs/getting-started/first-deployment-steps/step-install-guide/step6.png) |
| `./build.sh guest`   | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step7.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=40ef30b548825fcad8b6a41634ceb0e8" alt="" width="286" height="70" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step7.png" /><br />[step7.png](/docs/getting-started/first-deployment-steps/step-install-guide/step7.png)     |

***

## 3 – Start Core Services

```bash theme={null}
# 1. Key-management service
./target/release/dstack-kms --config kms.toml
# 2. Gateway
./target/release/dstack-gateway --config gateway.toml
# 3. Virtual-machine manager
./target/release/dstack-vmm --config vmm.toml
```

| Action            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Start `kms`       | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step9.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=ab897d96a6b7ec0b9d2ab82bad567265" alt="" width="1896" height="974" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step9.png" /><br />[step9.png](/docs/getting-started/first-deployment-steps/step-install-guide/step9.png)                                 |
| Start `gateway`   | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step10.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=6eb7ab4f8e96c4ee5ee28a6a0ba0ad94" alt="" width="992" height="372" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step10.png" /><br />[step10.png](/docs/getting-started/first-deployment-steps/step-install-guide/step10.png)                         |
| Start `vmm`       | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step11.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=6a750b3a3d6a94d683ba77736711e7a8" alt="" width="1010" height="376" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step11.png" /><br />[step11.png](/docs/getting-started/first-deployment-steps/step-install-guide/step11.png)                       |
| Open VMM UI       | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step12.0.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=93d5307608961b02e92f6b5be6bddbb9" alt="" width="1012" height="642" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step12.0.png" /><br />[step12.0.png](/docs/getting-started/first-deployment-steps/step-install-guide/step12.0.png)   |
| Verify components | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step12.1.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=c9cfabeb84430ebc6837ff51ca569c56" alt="" width="3558" height="1562" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step12.1.png" /><br />[step12.1.png](/docs/getting-started/first-deployment-steps/step-install-guide/step12.1.png) |
| Ready to deploy   | <img src="https://mintcdn.com/phalanetwork/3Ae8rJnmVcGqGijP/docs/getting-started/first-deployment-steps/step-install-guide/step12.2.png?fit=max&auto=format&n=3Ae8rJnmVcGqGijP&q=85&s=29ca68e0913136b9c7c68b659019c8e3" alt="" width="1492" height="1726" data-path="docs/getting-started/first-deployment-steps/step-install-guide/step12.2.png" /><br />[step12.2.png](/docs/getting-started/first-deployment-steps/step-install-guide/step12.2.png) |

***

## ✅ Next Step: Deploy Your First Application

By now you've successfully built and started all the core dstack components. Your dstack cluster is now ready to deploy confidential applications.

To continue with deploying your first application, visit:

[**dstack Deployment Walkthrough**](/docs/getting-started/deploying-applications)
