detee-sgx/build_server.sh

43 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -e
SCRIPT=$0
EXAMPLE=$1
EXEC=$2
if [ $# -eq 0 ] || [ "$EXAMPLE" != "https" ] && [ "$EXAMPLE" != "grpcs" ]; then
echo "usage: $SCRIPT https|grpcs [--run]"
exit 1
fi
FEATURES=$(if [ "$EXAMPLE" == "https" ]; then echo "actix-web,occlum"; else echo "tonic,occlum"; fi)
occlum-cargo build --release --example mratls_"${EXAMPLE}"_server --features="$FEATURES"
strip target/x86_64-unknown-linux-musl/release/examples/mratls_"${EXAMPLE}"_server
cat > server.yaml <<EOF
includes:
- base.yaml
targets:
- target: /bin
copy:
- files:
- ../target/x86_64-unknown-linux-musl/release/examples/mratls_${EXAMPLE}_server
- target: /lib
copy:
- files:
- /opt/occlum/toolchains/dcap_lib/musl/libocclum_dcap.so.0.1.0
EOF
rm -rf server_instance && mkdir server_instance && cd server_instance
occlum init && rm -rf image
cp ../Occlum.json ./
copy_bom -f ../server.yaml --root image --include-dir /opt/occlum/etc/template
# TODO: "--enable-edmm Y" must be only for platforms that support SGX2
occlum build --sign-key ../examples/signing_key.pem
occlum package server.tar.gz
if [ "$EXEC" == "--run" ]; then
occlum run /bin/mratls_${EXAMPLE}_server
fi