Skip to content

Commit 5ba46d5

Browse files
Merge pull request #19 from iExecBlockchainComputing/feature/docker-io-gramine-base
Feature/docker io gramine base
2 parents 322b48f + 7571ed3 commit 5ba46d5

File tree

3 files changed

+8
-92
lines changed

3 files changed

+8
-92
lines changed

Jenkinsfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
@Library('[email protected]') _
22

33
buildInfo = getBuildInfo()
4+
dockerIoVisibility = Registries.EXTERNAL_DOCKERIO_HOST
45

56
baseDir = 'cloud-computing'
67
nativeImage = buildSimpleDocker_v3(
78
buildInfo: buildInfo,
89
dockerfileDir: baseDir,
910
buildContext: baseDir,
1011
dockerImageRepositoryName: 'python-hello-world',
11-
visibility: 'docker.io'
12+
visibility: dockerIoVisibility
1213
)
1314

1415
stage('Build Gramine') {
1516
gramineBuildInfo = buildInfo.clone()
1617
dockerfileDir = baseDir + '/gramine'
1718
dockerImageRepositoryName = 'tee-python-hello-world'
1819
gramineBuildInfo.imageTag += '-gramine'
19-
visibility = 'iex.ec'
2020
productionImageName = ''
2121
stage('Build Gramine production image') {
2222
productionImageName = buildSimpleDocker_v3(
2323
buildInfo: gramineBuildInfo,
2424
dockerfileDir: dockerfileDir,
2525
buildContext: baseDir,
2626
dockerImageRepositoryName: dockerImageRepositoryName,
27-
visibility: visibility
27+
visibility: dockerIoVisibility
2828
)
2929
}
30-
stage('Build Gramine test CA Gramine image') {
30+
stage('Build Gramine test CA image') {
3131
testCaSuffix = 'test-ca'
3232
gramineBuildInfo.imageTag += '-' + testCaSuffix
3333
buildSimpleDocker_v3(
@@ -36,7 +36,7 @@ stage('Build Gramine') {
3636
dockerfileFilename: 'Dockerfile.' + testCaSuffix,
3737
dockerBuildOptions: '--build-arg BASE_IMAGE=' + productionImageName,
3838
dockerImageRepositoryName: dockerImageRepositoryName,
39-
visibility: visibility
39+
visibility: Registries.EXTERNAL_IEXEC_HOST
4040
)
4141
}
4242
}

cloud-computing/gramine/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# FIXME: use tagged version when released
2-
FROM docker-regis.iex.ec/iexec-gramine-base:0.9.0
1+
FROM iexechub/iexec-gramine-base:0.10.0
32

43
RUN apt-get install -y python3 && rm -rf /var/lib/apt/lists/* \
54
&& pip3 install pyfiglet

cloud-computing/gramine/README.md

Lines changed: 2 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,7 @@
1-
## How to run demo with Gramine on localhost
1+
## How to build your Gramine application
22

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:
174
```shell
185
docker build -t tee-gramine-python-hello-world:latest -f gramine/Dockerfile .
196
```
207
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

Comments
 (0)