Add SOFABoot demo
This commit is contained in:
parent
0f23ddb14e
commit
bd43e5b867
33
.github/workflows/demo_test.yml
vendored
33
.github/workflows/demo_test.yml
vendored
@ -509,3 +509,36 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
sleep ${{ env.nap_time }};
|
sleep ${{ env.nap_time }};
|
||||||
docker exec vault_test bash -c "cd /root/occlum/demos/golang/vault && ./run_occlum_vault_test.sh"
|
docker exec vault_test bash -c "cd /root/occlum/demos/golang/vault && ./run_occlum_vault_test.sh"
|
||||||
|
|
||||||
|
sofaboot_test:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
|
||||||
|
- name: Get occlum version
|
||||||
|
run: echo "OCCLUM_VERSION=$(grep "Version =" src/pal/include/occlum_version.h | awk '{print $4}')" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Create container
|
||||||
|
run: docker run -itd --name=sofaboot_test -v $GITHUB_WORKSPACE:/root/occlum occlum/occlum:${{ env.OCCLUM_VERSION }}-ubuntu18.04
|
||||||
|
|
||||||
|
- name: Install Maven
|
||||||
|
run: docker exec sofaboot_test bash -c "apt update && apt install -y maven"
|
||||||
|
|
||||||
|
- name: Build dependencies
|
||||||
|
run: docker exec sofaboot_test bash -c "cd /root/occlum; make submodule"
|
||||||
|
|
||||||
|
- name: Make install
|
||||||
|
run: docker exec sofaboot_test bash -c "cd /root/occlum; OCCLUM_RELEASE_BUILD=y make install"
|
||||||
|
|
||||||
|
- name: Download and compile sofaboot web demos
|
||||||
|
run: docker exec sofaboot_test bash -c "cd /root/occlum/demos/sofaboot && ./download_compile_sofaboot.sh"
|
||||||
|
|
||||||
|
- name: Run SOFABoot web demo
|
||||||
|
run: docker exec sofaboot_test bash -c "cd /root/occlum/demos/sofaboot && SGX_MODE=SIM ./run_sofaboot_on_occlum.sh"
|
||||||
|
|
||||||
|
- name: Check SOFABoot result
|
||||||
|
run: |
|
||||||
|
sleep ${{ env.nap_time }};
|
||||||
|
docker exec sofaboot_test bash -c "curl http://localhost:8080/actuator/versions"
|
||||||
|
18
demos/sofaboot/README.md
Normal file
18
demos/sofaboot/README.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# A Simple SOFABoot usage demo
|
||||||
|
|
||||||
|
This project demonstrates how to execute an unmodified sofaboot projects with Occlum.
|
||||||
|
|
||||||
|
1. Download and build sofaboot project
|
||||||
|
```
|
||||||
|
./download_compile_sofaboot.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Run `sofaboot sample standard web` on Occlum
|
||||||
|
```
|
||||||
|
./run_sofaboot_on_occlum.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Test the web services
|
||||||
|
```
|
||||||
|
curl http://localhost:8080/actuator/versions
|
||||||
|
```
|
7
demos/sofaboot/download_compile_sofaboot.sh
Executable file
7
demos/sofaboot/download_compile_sofaboot.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
if [ ! -d "sofa-boot-guides" ]; then
|
||||||
|
git clone https://github.com/sofastack-guides/sofa-boot-guides.git
|
||||||
|
fi
|
||||||
|
cd sofa-boot-guides/sofaboot-sample-standard/
|
||||||
|
mvn compile
|
||||||
|
mvn package
|
50
demos/sofaboot/run_sofaboot_on_occlum.sh
Executable file
50
demos/sofaboot/run_sofaboot_on_occlum.sh
Executable file
@ -0,0 +1,50 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
BLUE='\033[1;34m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
check_file_exist() {
|
||||||
|
file=$1
|
||||||
|
if [ ! -f ${file} ];then
|
||||||
|
echo "Error: cannot stat file '${file}'"
|
||||||
|
echo "Please see README and build it"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
init_instance() {
|
||||||
|
# Init Occlum instance
|
||||||
|
rm -rf occlum_instance && occlum new occlum_instance
|
||||||
|
cd occlum_instance
|
||||||
|
new_json="$(jq '.resource_limits.user_space_size = "1680MB" |
|
||||||
|
.resource_limits.kernel_space_heap_size="64MB" |
|
||||||
|
.resource_limits.max_num_of_threads = 64 |
|
||||||
|
.process.default_heap_size = "256MB" |
|
||||||
|
.process.default_mmap_size = "1400MB" |
|
||||||
|
.entry_points = [ "/usr/lib/jvm/java-11-alibaba-dragonwell/jre/bin" ] |
|
||||||
|
.env.default = [ "LD_LIBRARY_PATH=/usr/lib/jvm/java-11-alibaba-dragonwell/jre/lib/server:/usr/lib/jvm/java-11-alibaba-dragonwell/jre/lib:/usr/lib/jvm/java-11-alibaba-dragonwell/jre/../lib" ]' Occlum.json)" && \
|
||||||
|
echo "${new_json}" > Occlum.json
|
||||||
|
}
|
||||||
|
|
||||||
|
build_sofa() {
|
||||||
|
# Copy JVM and JAR file into Occlum instance and build
|
||||||
|
mkdir -p image/usr/lib/jvm
|
||||||
|
cp -r /opt/occlum/toolchains/jvm/java-11-alibaba-dragonwell image/usr/lib/jvm
|
||||||
|
cp /usr/local/occlum/x86_64-linux-musl/lib/libz.so.1 image/lib
|
||||||
|
mkdir -p image/usr/lib/spring
|
||||||
|
cp ../${jar_path} image/usr/lib/spring/
|
||||||
|
occlum build
|
||||||
|
}
|
||||||
|
|
||||||
|
run_sofa() {
|
||||||
|
jar_path=./sofa-boot-guides/sofaboot-sample-standard/target/boot/sofaboot-sample-standard-web-0.0.1-SNAPSHOT-executable.jar
|
||||||
|
check_file_exist ${jar_path}
|
||||||
|
jar_file=`basename "${jar_path}"`
|
||||||
|
init_instance
|
||||||
|
build_sofa
|
||||||
|
echo -e "${BLUE}occlum run SOFABoot demo${NC}"
|
||||||
|
occlum run /usr/lib/jvm/java-11-alibaba-dragonwell/jre/bin/java -Xmx512m -XX:-UseCompressedOops -XX:MaxMetaspaceSize=64m -Dos.name=Linux -jar /usr/lib/spring/${jar_file} &
|
||||||
|
}
|
||||||
|
|
||||||
|
run_sofa
|
Loading…
Reference in New Issue
Block a user