|
| 1 | +<!-- |
| 2 | +SPDX-FileCopyrightText: © 2026 Phala Network <dstack@phala.network> |
| 3 | +SPDX-License-Identifier: Apache-2.0 |
| 4 | +--> |
| 5 | + |
| 6 | +# dstack full-stack compose E2E suite |
| 7 | + |
| 8 | +This directory contains a Docker Compose based test suite that mirrors the |
| 9 | +`tdxlab`/`dstack-k8s deploy/compose` shape: host-side services run as normal |
| 10 | +processes/containers, and QEMU is used only for the real app CVM under test. |
| 11 | + |
| 12 | +```text |
| 13 | +docker compose |
| 14 | + ├─ mock-cf-dns-api # tiny Cloudflare API + TXT DNS mock |
| 15 | + ├─ pebble # ACME test server (HTTP-capable custom Pebble image) |
| 16 | + ├─ aesmd + local-keyprovider |
| 17 | + ├─ dstack-auth # KMS auth webhook backed by auth-allowlist.json |
| 18 | + ├─ dstack-kms # host-side dev KMS, not a CVM |
| 19 | + ├─ dstack-gateway # host-side dev Gateway, not a CVM |
| 20 | + ├─ dstack-vmm # launches real TDX/SNP app CVMs via QEMU |
| 21 | + └─ runner |
| 22 | + ├─ configures Gateway certbot to use mock CF + Pebble |
| 23 | + ├─ deploys nginx test app CVM with kms_enabled=true + gateway_enabled=true |
| 24 | + └─ verifies HTTPS Gateway -> app routing |
| 25 | +``` |
| 26 | + |
| 27 | +It is intended for a **real TDX/SGX host** (or SEV-SNP host after setting the |
| 28 | +platform/image knobs). It is not a pure unit-test environment; QEMU still starts |
| 29 | +a confidential VM for the app. |
| 30 | + |
| 31 | +## Prerequisites |
| 32 | + |
| 33 | +1. From this directory, build the host binaries from the dstack checkout: |
| 34 | + |
| 35 | + ```bash |
| 36 | + cargo build --release \ |
| 37 | + --manifest-path ../../dstack/Cargo.toml \ |
| 38 | + -p dstack-cli -p dstack-auth -p dstack-vmm -p dstack-kms \ |
| 39 | + -p dstack-gateway -p supervisor |
| 40 | + ``` |
| 41 | + |
| 42 | +2. Make sure the host has the required devices/services: |
| 43 | + |
| 44 | + - `/dev/kvm` |
| 45 | + - Intel TDX support and QGS for TDX (`DSTACK_E2E_QGS_PORT`, default `4050`) |
| 46 | + - `/dev/sgx_enclave` and `/dev/sgx_provision` for the local key provider |
| 47 | + - an SGX QCNL config that works on the host. By default the suite uses |
| 48 | + `../../dstack/key-provider-build/sgx_default_qcnl.conf`; on hosts with a local |
| 49 | + PCCS, set `DSTACK_E2E_QCNL_CONF=/etc/sgx_default_qcnl.conf`. |
| 50 | + - `/dev/vhost-vsock` for guest↔host vsock services |
| 51 | + - a TDX-capable `qemu-system-x86_64` available inside the runtime container. |
| 52 | + The default runtime image follows `../dstack-k8s/deploy/compose` and |
| 53 | + installs QEMU from `ppa:kobuk-team/tdx-release`. |
| 54 | + - WireGuard kernel support on the host. The Gateway service runs privileged |
| 55 | + with host networking and creates `DSTACK_E2E_GATEWAY_WG_INTERFACE`. |
| 56 | + |
| 57 | +3. Provide an unpacked guest image store. From `meta-dstack` this is usually |
| 58 | + `../../../build/images`; otherwise copy `.env.example` and set: |
| 59 | + |
| 60 | + ```bash |
| 61 | + cp .env.example .env |
| 62 | + $EDITOR .env |
| 63 | + ``` |
| 64 | + |
| 65 | +No Gateway image publishing is needed in this architecture: `dstack-gateway` and |
| 66 | +`dstack-kms` are run from the local `target/release/` binaries on the host side. |
| 67 | + |
| 68 | +## Run |
| 69 | + |
| 70 | +From this directory, run: |
| 71 | + |
| 72 | +```bash |
| 73 | +DOCKER_BUILDKIT=0 docker compose --env-file .env -f compose.yml up --build --abort-on-container-exit runner |
| 74 | +``` |
| 75 | + |
| 76 | +For iterative debugging, keep the stack running: |
| 77 | + |
| 78 | +```bash |
| 79 | +DOCKER_BUILDKIT=0 docker compose --env-file .env -f compose.yml up --build |
| 80 | +``` |
| 81 | + |
| 82 | +The runner leaves the app VM running by default for inspection. Set |
| 83 | +`DSTACK_E2E_CLEANUP_AFTER=true` to remove suite VMs at the end. Stale VMs whose |
| 84 | +names start with `DSTACK_E2E_NAME_PREFIX` are removed at the start when |
| 85 | +`DSTACK_E2E_CLEAN_START=true`. |
| 86 | + |
| 87 | +## What is verified |
| 88 | + |
| 89 | +The runner checks: |
| 90 | + |
| 91 | +1. Host-side KMS is reachable over TLS. |
| 92 | +2. Host-side Gateway Admin API accepts configuration. |
| 93 | +3. Gateway obtains a wildcard certificate for `*.DSTACK_E2E_BASE_DOMAIN` from |
| 94 | + Pebble using the mock Cloudflare DNS API. |
| 95 | +4. VMM API becomes reachable. |
| 96 | +5. A real nginx app CVM boots with `kms_enabled=true` and `gateway_enabled=true`. |
| 97 | +6. `curl -k` through the Gateway SNI route returns the nginx welcome page. |
| 98 | + |
| 99 | +Artifacts are written under `state/work/`. |
| 100 | + |
| 101 | +## Notes / flexibility gaps |
| 102 | + |
| 103 | +- This is a dev compose KMS/Gateway setup. KMS and Gateway key material is |
| 104 | + generated under `state/`; the allowlist returns `gatewayAppId = "any"`, which |
| 105 | + matches the host-side tdxlab-style deployment and avoids requiring Gateway to |
| 106 | + be a CVM. |
| 107 | +- `dstackup install` is systemd-oriented; this suite renders `vmm.toml`, |
| 108 | + `kms.toml`, `gateway.toml`, and `auth-allowlist.json` itself. |
| 109 | +- Running VMM in a container depends on the container image having a QEMU build |
| 110 | + that supports the target TEE platform. The runtime Dockerfile uses Intel's |
| 111 | + kobuk-team TDX PPA for QEMU, matching the dstack-k8s compose deployment. |
| 112 | +- Host API is vsock-only by design. The suite therefore uses privileged host |
| 113 | + networking and a separate `DSTACK_E2E_HOST_API_PORT` to avoid conflicts with |
| 114 | + other VMM instances. |
0 commit comments