README.md 3.7 KB
Newer Older
1 2 3
The files in this directory are used to implement a skeleton enclave runtime,
in order to help to write your own enclave runtime.

4
# Install runectl
5
Refer to [this guide](https://github.com/alibaba/inclavare-containers/tree/master/runectl)
6

7 8
# Build liberpal-skeleton.so
```shell
9 10
cd "${path_to_inclavare_containers}/rune/libenclave/internal/runtime/pal/skeleton"
make
11
cp liberpal-skeletion.so /usr/lib
12 13 14 15
```

# Build skeleton docker image
```shell
16
cd "${path_to_inclavare_containers}/rune/libenclave/internal/runtime/pal/skeleton"
17
cat >Dockerfile <<EOF
18
FROM centos:7.5.1804
19 20 21 22

RUN mkdir -p /run/rune
WORKDIR /run/rune

23 24 25 26
COPY encl.bin .
COPY encl.elf .
COPY encl.ss .
COPY encl.token .
27 28 29 30
EOF
docker build . -t liberpal-skeleton
```

31
# Build and install rune
32 33 34 35
`rune` is a CLI tool for spawning and running enclaves in containers according to the OCI specification.

Please refer to [this guide](https://github.com/alibaba/inclavare-containers#rune) to build `rune` from scratch.

36
# Run skeleton docker image
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
## Configure Docker runtimes
Add the `rune` OCI runtime configuration in dockerd config file (`/etc/docker/daemon.json`) in your system.

``` JSON
{
	"runtimes": {
		"rune": {
			"path": "/usr/local/sbin/rune",
			"runtimeArgs": []
		}
	}
}
```

then restart docker service on your system.
> e.g. `sudo systemctl restart docker` for CentOS, or `sudo service docker restart` for Ubuntu

You can check whether `rune` is correctly added to container runtime or not with
``` shell
sudo docker info | grep rune
Runtimes: rune runc
```

## Run skeleton docker image with rune
61 62 63
```shell
docker run -it --rm --runtime=rune \
  -e ENCLAVE_TYPE=intelSgx \
64
  -e ENCLAVE_RUNTIME_PATH=/usr/lib/liberpal-skeleton.so \
65
  -e ENCLAVE_RUNTIME_ARGS="debug" \
66 67
  liberpal-skeleton
```
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

where:
- @runtime: choose the runtime (`rune`, `runc` or others) to use for this container.
- @ENCLAVE_TYPE: specify the type of enclave hardware to use, such as `intelSgx`.
- @ENCLAVE_PATH: specify the path to enclave runtime to launch.
- @ENCLAVE_ARGS: specify the specific arguments to enclave runtime, seperated by the comma.

# Run skeleton OCI bundle
## Create skeleton bundle
In order to use `rune` you must have your container in the format of an OCI bundle. If you have Docker installed you can use its `export` method to acquire a root filesystem from an existing skeleton Docker container.

``` shell
# create the top most bundle directory
cd "$HOME/rune_workdir"
mkdir rune-container
cd rune-container

# create the rootfs directory
mkdir rootfs

# export skeleton image via Docker into the rootfs directory
docker export $(docker create liberpal-skeleton) | sudo tar -C rootfs -xvf -
```

After a root filesystem is populated you just generate a spec in the format of a config.json file inside your bundle. `rune` provides a spec command which is similar to `runc` to generate a template file that you are then able to edit.

``` shell
rune spec
```

To find features and documentation for fields in the spec please refer to the [specs](https://github.com/opencontainers/runtime-spec) repository.

In order to run the skeleton bundle with `rune`, you need to configure enclave runtime as following:
``` json
  "annotations": {
      "enclave.type": "intelSgx",
      "enclave.runtime.path": "/usr/lib/liberpal-skeleton.so",
      "enclave.runtime.args": "debug"
  }
```

where:

- @enclave.type: specify the type of enclave hardware to use, such as intelSgx.
- @enclave.runtime.path: specify the path to enclave runtime to launch.
- @enclave.runtime.args: specify the specific arguments to enclave runtime, seperated by the comma.
---

## Run skeleton application
Assuming you have an OCI bundle from the previous step you can execute the container in this way.

``` shell
cd "$HOME/rune_workdir/rune-container"
sudo rune run "liberpal-skeleton"
```