|
1 |
| -## How to run demo with Gramine on localhost |
| 1 | +## How to build your Gramine application |
2 | 2 |
|
3 |
| -1. Start a SPS container: |
4 |
| -```shell |
5 |
| -SPS_VERSION=<set SPS version here> |
6 |
| -docker run -d \ |
7 |
| - -v /opt/multiple/sessions:/graphene/workplace/sessions \ |
8 |
| - -v /opt/secret-prov/certs/:/graphene/workplace/certs \ |
9 |
| - -p 8080:8080 -p 4433:4433 \ |
10 |
| - -e SPS_USERNAME=admin -e SPS_PASSWORD=admin \ |
11 |
| - --name iexec-sps \ |
12 |
| - iexechub/iexec-sps:${SPS_VERSION} |
13 |
| -``` |
14 |
| - |
15 |
| - |
16 |
| -2. Build your app (from `cloud-computing` directory) : |
| 3 | +Go to the `cloud-computing/` directory, then: |
17 | 4 | ```shell
|
18 | 5 | docker build -t tee-gramine-python-hello-world:latest -f gramine/Dockerfile .
|
19 | 6 | ```
|
20 | 7 | Please note the `measurement` value.
|
21 |
| - |
22 |
| - |
23 |
| -3. To add a session to the SPS, run the following after having filled both env var: |
24 |
| -```shell |
25 |
| -SESSION_ID=<define your custom session id> |
26 |
| -MEASUREMENT=<set previous retrieved measurement> |
27 |
| - |
28 |
| -curl --location --request POST 'localhost:8080/api/session/' \ |
29 |
| ---header 'Authorization: Basic YWRtaW46YWRtaW4=' \ |
30 |
| ---header 'Content-Type: application/json' \ |
31 |
| ---data-raw '{ |
32 |
| - "session": "'${SESSION_ID}'", |
33 |
| - "enclaves": [ |
34 |
| - { |
35 |
| - "name": "app", |
36 |
| - "mrenclave": "'${MEASUREMENT}'", |
37 |
| - "command": "/apploader.sh", |
38 |
| - "environment": { |
39 |
| - "IEXEC_IN": "/iexec_in", |
40 |
| - "IEXEC_OUT": "/iexec_out", |
41 |
| - "IEXEC_DATASET_FILENAME": "file.txt", |
42 |
| - "IEXEC_INPUT_FILES_NUMBER": "1", |
43 |
| - "IEXEC_INPUT_FILE_NAME_1": "file.txt", |
44 |
| - "IEXEC_TASK_ID": "TASK_ID", |
45 |
| - "IEXEC_APP_DEVELOPER_SECRET": "App developer secret", |
46 |
| - "IEXEC_REQUESTER_SECRET_1": "Requester secret 1", |
47 |
| - "IEXEC_REQUESTER_SECRET_2": "Requester secret 2", |
48 |
| - "IEXEC_REQUESTER_SECRET_3": "Requester secret 3" |
49 |
| - }, |
50 |
| - "volumes": [ |
51 |
| - ] |
52 |
| - } |
53 |
| - ] |
54 |
| -}' |
55 |
| -``` |
56 |
| - |
57 |
| - |
58 |
| -4. Run the app: |
59 |
| -```shell |
60 |
| -docker run \ |
61 |
| - --device=/dev/sgx/enclave \ |
62 |
| - -v /iexec_in:/iexec_in -v /tmp/iexec_out:/iexec_out \ |
63 |
| - -v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket \ |
64 |
| - -v $PWD/encryptedData:/workplace/encryptedData \ |
65 |
| - -v /opt/secret-prov/certs/:/graphene/attestation/certs/ \ |
66 |
| - --net=host \ |
67 |
| - -e session=${SESSION_ID} -e sps=localhost:4433 \ |
68 |
| - tee-gramine-python-hello-world:latest |
69 |
| -``` |
70 |
| - |
71 |
| - |
72 |
| -### Troubleshooting: |
73 |
| - |
74 |
| -#### "Get keys failed" |
75 |
| -When the app can't communicate with the SPS, you can encounter some numeric error codes, in the following format: |
76 |
| -``` |
77 |
| -[error] connect to kms failed, kms_endpoint is iexec-sps:4433, cert_path is /graphene/attestation/certs/test-ca-sha256.crt |
78 |
| -[error] get keys failed, return -[ERROR_CODE] |
79 |
| -``` |
80 |
| - |
81 |
| -Depending on the error code, the issue is the following: |
82 |
| - |
83 |
| -| Error code | Error | Solution | |
84 |
| -|:----------:|:-----------------:|:-------------------------------------------------------------------------------------------------------------------------:| |
85 |
| -| 111 | Can't reach SPS | Check SPS IP is correct in app configuration. | |
86 |
| -| 9984 | Certificate error | Check both app & SPS share a valid certificate. Regenerate it if needed, providing SPS IP as `Common Name` when prompted. | |
87 |
| - |
88 |
| - |
89 |
| -#### Dataset and input files are not correctly read |
90 |
| -Check they are correctly added as `sgx.allowed_files` in `entrypoint.manifest`. |
0 commit comments