occlum/demos/golang/run_golang_on_occlum.sh
LI Qing 6d72e10fc1 Add Golang toolchain and the demo
This commit provides a modified Go runtime in Docker image.
Now we can build a Go program using `occlum-go`, then run it
in SGX enclaves by Occlum.
The Golang demo demonstrates how to build and run a web server
program written in Go.
2020-05-15 03:02:42 +00:00

29 lines
686 B
Bash
Executable File

#!/bin/bash
set -e
BLUE='\033[1;34m'
NC='\033[0m'
web_server="./web_server"
if [ ! -f $web_server ];then
echo "Error: cannot stat file '$web_server'"
echo "Please see README and build it using Occlum Golang toolchain"
exit 1
fi
# 1. Init Occlum Workspace
rm -rf occlum_context && mkdir occlum_context
cd occlum_context
occlum init
jq '.vm.user_space_size = "320MB"' Occlum.json > temp_Occlum.json
jq '.process.default_mmap_size = "256MB"' temp_Occlum.json > Occlum.json
# 2. Copy program into Occlum Workspace and build
cp ../web_server image/bin
occlum build
# 3. Run the hello world sample
echo -e "${BLUE}occlum run /bin/web_server${NC}"
occlum run /bin/web_server