-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (108 loc) · 4.04 KB
/
Makefile
File metadata and controls
133 lines (108 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
SHELL := /bin/bash
.DELETE_ON_ERROR:
.DEFAULT_GOAL := help
ENCLAVE_CID ?= 16
ENCLAVE_MEMORY ?= 512
ENCLAVE_CPU_COUNT ?= 2
SERVER_IP ?= 127.0.0.1
SERVER_PORT ?= 8080
# ---------------------------------------------------------------------------
# Help
# ---------------------------------------------------------------------------
COLOR_CYAN := "\033[36m"
COLOR_RESET := "\033[0m"
PADDING := 20
.PHONY: help
help: ## Show help
@printf "%-$(PADDING)s %s\n" "TARGET" "DESCRIPTION"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf $(COLOR_CYAN)"%-$(PADDING)s"$(COLOR_RESET) " %s\n", $$1, $$2}'
# ---------------------------------------------------------------------------
# Clean
# ---------------------------------------------------------------------------
.PHONY: clean
clean: ## Clean build artifacts
@echo "Cleaning build artifacts"
cargo clean
-docker rmi rafwne-enclave
rm -f rafwne-enclave.eif
rm -f root.pem
# ---------------------------------------------------------------------------
# Setup
# ---------------------------------------------------------------------------
.PHONY: setup-docker
setup-docker: ## Install Docker (requires Ubuntu + sudo)
@echo "Running scripts/setup-docker.sh"
bash ./scripts/setup-docker.sh
.PHONY: setup-nitro-cli
setup-nitro-cli: ## Install Nitro Enclaves Driver and CLI
@echo "Running scripts/setup-nitro-cli.sh"
bash ./scripts/setup-nitro-cli.sh
.PHONY: setup-client
setup-client: ## Install Rust and dependencies
@echo "Running scripts/setup-client.sh"
bash ./scripts/setup-client.sh
.PHONY: download-root-ca
download-root-ca: ## Download AWS Nitro Enclaves root CA certificate
@echo "Running scripts/download-root-ca.sh"
bash ./scripts/download-root-ca.sh
# ---------------------------------------------------------------------------
# Build
# ---------------------------------------------------------------------------
rafwne-enclave.eif: ## Build enclave Docker image and create EIF file
@echo "Building Docker image"
docker build -t rafwne-enclave .
@echo "Creating EIF file"
nitro-cli build-enclave --docker-uri rafwne-enclave --output-file rafwne-enclave.eif
.PHONY: build-enclave
build-enclave: rafwne-enclave.eif
target/release/rafwne-proxy:
@echo "Building vsock proxy"
cargo build -p rafwne-proxy -r
.PHONY: build-proxy
build-proxy: target/release/rafwne-proxy ## Build vsock proxy
target/release/rafwne-client:
@echo "Building client crate (release)"
cargo build -p rafwne-client -r
.PHONY: build-client
build-client: target/release/rafwne-client ## Build client application
# ---------------------------------------------------------------------------
# Run
# ---------------------------------------------------------------------------
.PHONY: run-enclave
run-enclave: rafwne-enclave.eif ## Run Nitro Enclave
@echo "Running Nitro Enclave"
nitro-cli run-enclave \
--eif-path rafwne-enclave.eif \
--memory $(ENCLAVE_MEMORY) \
--cpu-count $(ENCLAVE_CPU_COUNT) \
--enclave-cid $(ENCLAVE_CID)
.PHONY: run-proxy
run-proxy: target/release/rafwne-proxy ## Run vsock proxy
@echo "Running vsock proxy"
./target/release/rafwne-proxy \
--ip $(SERVER_IP) \
--port $(SERVER_PORT) \
--cid $(ENCLAVE_CID)
.PHONY: run-client
run-client: target/release/rafwne-client root.pem ## Run client application
@echo "Running client"
./target/release/rafwne-client
# ---------------------------------------------------------------------------
# Terminate
# ---------------------------------------------------------------------------
.PHONY: terminate-enclave
terminate-enclave: ## Terminate Nitro Enclave
@echo "Terminating Nitro Enclave"
@ENCLAVE_ID=$$(nitro-cli describe-enclaves \
| jq -r --argjson cid $(ENCLAVE_CID) \
'.[] | select(.State == "RUNNING" and .EnclaveCID == $$cid) | .EnclaveID' \
| head -n1); \
if [ -z "$$ENCLAVE_ID" ]; then \
echo "ERROR: running enclave with CID=$(ENCLAVE_CID) not found"; \
nitro-cli describe-enclaves; \
exit 1; \
fi; \
echo "Enclave ID: $$ENCLAVE_ID"; \
nitro-cli terminate-enclave --enclave-id "$$ENCLAVE_ID"; \
echo "Enclave terminated"