forked from Dstack-TEE/dstack-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
43 lines (39 loc) · 1.38 KB
/
Copy pathdocker-compose.yml
File metadata and controls
43 lines (39 loc) · 1.38 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
services:
tapp:
configs:
- source: run.sh
target: run.sh
volumes:
- /var/run/tappd.sock:/var/run/tappd.sock
build:
context: .
dockerfile_inline: |
FROM ubuntu:22.04@sha256:01a3ee0b5e413cefaaffc6abe68c9c37879ae3cced56a8e088b1649e5b269eee
RUN apt-get update
RUN apt install -y curl openssl ntpsec-ntpdate
command: bash run.sh
platform: linux/amd64
configs:
run.sh:
content: |-
#!/bin/bash
key=$$(openssl genpkey -algorithm Ed25519)
echo "Public Key:"; echo "$$key" | openssl pkey -pubout
# Get timestamp from cloudflare and add 5 minutes
get_time() { ntpdate -4q time.cloudflare.com 2>/dev/null | head -1 | cut -d' ' -f1,2 | date +%s -f -; }
deadline=$$(($$(get_time) + 300))
deadline_str=$$(date -d @$${deadline})
echo "Release: $$deadline_str"
# Fetch the quote
get_quote() {
PAYLOAD="{\"report_data\": \"$$(echo -n $$1 | od -A n -t x1 | tr -d ' \n')\"}"
curl -X POST --unix-socket /var/run/tappd.sock -d "$$PAYLOAD" http://localhost/prpc/Tappd.TdxQuote?json
}
get_quote $$(echo $$key $$deadline_str | sha256sum)
echo
# Loop until it's time to release the key
while [ $$(get_time) -lt $$deadline ]; do
echo "$$((deadline - $$(get_time)))s left"
sleep 60
done
echo "Private Key:"; echo "$$key"