Skip to content

Commit a0e6643

Browse files
committed
build: added scripts for local tee/sgx development
1 parent 92d7b59 commit a0e6643

File tree

4 files changed

+88
-13
lines changed

4 files changed

+88
-13
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -304,24 +304,17 @@ jobs:
304304
CONTAINER_REGISTRY: ghcr.io
305305
if: github.ref == 'refs/heads/dev' || (startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.'))
306306
steps:
307+
- name: Checkout repository
308+
uses: actions/checkout@v4
309+
with:
310+
sparse-checkout: './crates/notary/server/tee/notary-server-sgx.Dockerfile'
311+
307312
- name: Download notary-server-sgx.zip from gramine-sgx job
308313
uses: actions/download-artifact@v4
309314
with:
310315
name: notary-server-sgx.zip
311316
path: ./notary-server-sgx
312317

313-
- name: Create Dockerfile
314-
run: |
315-
cat <<EOF > ./Dockerfile
316-
FROM gramineproject/gramine:latest
317-
WORKDIR /work
318-
COPY ./notary-server-sgx /work
319-
RUN chmod +x /work/notary-server
320-
LABEL org.opencontainers.image.source=https://github.com/tlsnotary/tlsn
321-
LABEL org.opencontainers.image.description="TLSNotary notary server in SGX/Gramine."
322-
ENTRYPOINT ["gramine-sgx", "notary-server"]
323-
EOF
324-
325318
- name: Log in to the Container registry
326319
uses: docker/login-action@v2
327320
with:
@@ -342,7 +335,8 @@ jobs:
342335
push: true
343336
tags: ${{ steps.meta-notary-server-sgx.outputs.tags }}
344337
labels: ${{ steps.meta-notary-server-sgx.outputs.labels }}
345-
file: ./Dockerfile
338+
file: ./crates/notary/server/tee/notary-server-sgx.Dockerfile
339+
346340
build_and_publish_notary_server_image:
347341
name: Build and publish notary server's image
348342
runs-on: ubuntu-latest
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM --platform=linux/amd64 gramineproject/gramine:latest
2+
3+
RUN apt update && \
4+
apt install -y jq openssl zip && \
5+
apt clean && \
6+
rm -rf /var/lib/apt/lists/*
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM gramineproject/gramine:latest
2+
WORKDIR /work
3+
4+
# This copies the contents of `notary-server-sgx.zip` from the ci build step into the container.
5+
# This zip file can also be created locally with `run-gramine-local.sh` in the `crates/notary/server/tee` directory.
6+
# This zip file contains the notary-server binary and the Gramine manifest and signatures.
7+
COPY ./notary-server-sgx /work
8+
RUN chmod +x /work/notary-server
9+
10+
LABEL org.opencontainers.image.source=https://github.com/tlsnotary/tlsn
11+
LABEL org.opencontainers.image.description="TLSNotary notary server in SGX/Gramine."
12+
13+
ENTRYPOINT ["gramine-sgx", "notary-server"]
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
3+
# This script is used to build and run the Gramine manifest for the Notary server in a local development environment.
4+
# It is intended to be run inside a Docker container with the Gramine SDK installed.
5+
6+
# The Dockerfile used to build the container is located in the same directory as this script.
7+
# The Dockerfile is named "Dockerfile.gramine-local" and is used to create a container with the necessary dependencies
8+
# and tools to build and run the Gramine manifest.
9+
10+
# To build the Docker image, run the following command:
11+
# ```
12+
# docker build -f Dockerfile.gramine-local -t gramine-local .
13+
# ```
14+
15+
# ⚠️ This script assumes that the notary-server binary is already built (for linux/amd64) and available in the current directory.
16+
17+
# To run the script inside the Docker container, use the following command:
18+
# ```
19+
# docker run --rm -it --platform=linux/amd64 -v "${PWD}:/app" -w /app/ gramine-local "bash -c ./run-gramine-local.sh"
20+
# ```
21+
22+
set -euo pipefail
23+
24+
echo "[*] Generating SGX signing key..."
25+
gramine-sgx-gen-private-key
26+
27+
chmod +x notary-server
28+
29+
echo "[*] Creating Gramine manifest..."
30+
gramine-manifest \
31+
-Dlog_level=debug \
32+
-Darch_libdir=/lib/x86_64-linux-gnu \
33+
-Dself_exe=notary-server \
34+
notary-server.manifest.template \
35+
notary-server.manifest
36+
37+
echo "[*] Signing manifest..."
38+
gramine-sgx-sign \
39+
--manifest notary-server.manifest \
40+
--output notary-server.manifest.sgx
41+
42+
echo "[*] Viewing SIGSTRUCT..."
43+
gramine-sgx-sigstruct-view --verbose --output-format=json notary-server.sig >notary-server-sigstruct.json
44+
45+
cat notary-server-sigstruct.json | jq .
46+
47+
mr_enclave=$(jq -r ".mr_enclave" notary-server-sigstruct.json)
48+
mr_signer=$(jq -r ".mr_signer" notary-server-sigstruct.json)
49+
50+
echo "=============================="
51+
echo "MRENCLAVE: $mr_enclave"
52+
echo "MRSIGNER: $mr_signer"
53+
echo "=============================="
54+
55+
zip -r notary-server-sgx.zip \
56+
notary-server \
57+
notary-server-sigstruct.json \
58+
notary-server.sig \
59+
notary-server.manifest \
60+
notary-server.manifest.sgx \
61+
config \
62+
notary-server-sgx.md

0 commit comments

Comments
 (0)