Git Product home page Git Product logo

examples's Introduction

Wetee TEE Image build guide

1 Ego docker image build

1.1 Clone the repository

git clone https://github.com/wetee-dao/examples
cd examples
cp -R ego-template my-ego-app
cd my-ego-app

1.2 Add golang main.go

# add main.go
echo 'package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}' > main.go

# build executable bin
ego-go build main.go

1.3 Modify Dockerfile

FROM wetee/ego-ubuntu-deploy:22.04
WORKDIR /

# Add executable file and files
ADD main  /main
# Add end

ADD keys   /keys
ADD enclave.json /enclave.json

ENTRYPOINT ["/bin/sh", "-c" ,"ego sign main && ego run main"]

1.4 Build docker image

docker build -t my-ego-app .

1.5 Run docker image

docker run --device /dev/sgx/enclave --device /dev/sgx/provision my-ego-app

2 Gramine docker image build

2.1 Clone the repository

git clone https://github.com/wetee-dao/examples
cd examples
cp -R gramine-template my-gramine-app
cd my-gramine-app

2.2 Add a rust test project

# create a new rust project
cargo init
cargo build

2.3 Modify app.manifest.template config loader.argv fs.mounts sgx.trusted_files sgx.allowed_files

loader.entrypoint = "file:{{ gramine.libos }}"
libos.entrypoint = "libos-entry"

loader.log_level = "{{ log_level }}"

loader.env.LD_LIBRARY_PATH = "/lib:{{ arch_libdir }}:/usr{{ arch_libdir }}"
loader.env.IN_TEE = { passthrough = true }
loader.env.APPID = { passthrough = true }
loader.env.WORKER_ADDR = { passthrough = true }

# Gramine add run CMD
loader.argv = ["/opt/rust/my-gramine-app"]
# Gramine add run CMD end


loader.uid = 1000
loader.gid = 1000

sys.enable_sigterm_injection = true
sys.enable_extra_runtime_domain_names_conf = true

fs.mounts = [
  { path = "{{ gramine.runtimedir() }}", uri = "file:{{ gramine.runtimedir() }}" },
  { path = "{{ arch_libdir }}", uri = "file:{{ arch_libdir }}" },
  { path = "/usr{{ arch_libdir }}", uri = "file:/usr{{ arch_libdir }}" },
  { type = "encrypted", key_name = "_sgx_mrsigner", path = "/wetee", uri = "file:/wetee" },
  # Gramine add mount
   { path = "/opt/rust", uri = "file:/opt/rust" },
  # Gramine add mount end
]

sgx.debug = true
sgx.edmm_enable = {{ 'true' if env.get('EDMM', '0') == '1' else 'false' }}
sgx.enclave_size = "1024M"
# sgx.max_threads = {{ '1' if env.get('EDMM', '0') == '1' else '4' }}
sgx.max_threads = 32

sgx.trusted_files = [
  "file:{{ gramine.libos }}",
  "file:{{ gramine.runtimedir() }}/",
  "file:{{ arch_libdir }}/",
  "file:/usr/{{ arch_libdir }}/",
  "file:libos-entry",
  # Gramine add trusted file
  "file:/opt/rust/my-gramine-app",
  # Gramine add trusted file end
]


sgx.allowed_files = [
  "file:/etc/hosts",
  "file:/etc/host.conf",
  "file:/etc/gai.conf",
  "file:/etc/resolv.conf",
  "file:/etc/localtime",
  "file:/etc/nsswitch.conf",
  "file:/wetee/",
  # Gramine add file

]

# enable DCAP
sgx.remote_attestation = "dcap"

2.4 Build docker image

  • Modify Dockerfile
FROM wetee/gramine-ubuntu:22.04

# app install
ADD target/debug/my-gramine-app /opt/rust/
# app install end

ADD app.manifest.template /

RUN gramine-sgx-gen-private-key \
    && gramine-manifest -Dlog_level=error -Darch_libdir=/lib/x86_64-linux-gnu app.manifest.template app.manifest

RUN mkdir /wetee

ENTRYPOINT ["/bin/sh", "-c" ,"/init_aesm.sh && gramine-sgx-sign --manifest app.manifest --output app.manifest.sgx && gramine-sgx app"]
  • Build docker image
docker build -t my-app .

2.5 Run docker image

docker run --device /dev/sgx/enclave --device /dev/sgx/provision my-app

examples's People

Contributors

burnww avatar

Watchers

Nomad Chen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.