Update sofaboot demo with openjdk 8 option
Signed-off-by: Zheng, Qi <huaiqing.zq@antgroup.com>
This commit is contained in:
		
							parent
							
								
									6d9d165a95
								
							
						
					
					
						commit
						8cb08aac29
					
				| @ -3,11 +3,26 @@ | ||||
| This project demonstrates how to execute an unmodified sofaboot projects with Occlum. | ||||
| 
 | ||||
| 1. Download and build sofaboot project | ||||
| 
 | ||||
| * Use openjdk 8 | ||||
| ``` | ||||
| ./download_compile_sofaboot.sh jdk8 | ||||
| ``` | ||||
| 
 | ||||
| * Use openjdk 11 | ||||
| ``` | ||||
| ./download_compile_sofaboot.sh | ||||
| ``` | ||||
| 
 | ||||
| 
 | ||||
| 2. Run `sofaboot sample standard web` on Occlum | ||||
| 
 | ||||
| * Run with openjdk 8 | ||||
| ``` | ||||
| ./run_sofaboot_on_occlum_jdk8.sh | ||||
| ``` | ||||
| 
 | ||||
| * Run with openjdk 11 | ||||
| ``` | ||||
| ./run_sofaboot_on_occlum.sh | ||||
| ``` | ||||
|  | ||||
| @ -1,7 +1,23 @@ | ||||
| #!/bin/bash | ||||
| set -e | ||||
| 
 | ||||
| if [[ $1 == "jdk8" ]]; then | ||||
|     echo "" | ||||
|     echo "*** Build sofaboot demo with openjdk 8 ***" | ||||
|     echo "*** Make sure openjdk 8 is installed ***" | ||||
|     mvn -v | grep "java-8" | ||||
| else | ||||
|     echo "" | ||||
|     echo "*** Build sofaboot demo with openjdk 11 ***" | ||||
|     echo "*** Make sure openjdk 11 is installed ***" | ||||
|     mvn -v | grep "java-11" | ||||
| fi | ||||
| 
 | ||||
| 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 clean | ||||
| mvn compile | ||||
| mvn package | ||||
|  | ||||
							
								
								
									
										47
									
								
								demos/sofaboot/run_sofaboot_on_occlum_jdk8.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										47
									
								
								demos/sofaboot/run_sofaboot_on_occlum_jdk8.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,47 @@ | ||||
| #!/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-1.8-openjdk/jre/bin" ] | | ||||
|                 .env.default = [ "LD_LIBRARY_PATH=/usr/lib/jvm/java-1.8-openjdk/jre/lib:/usr/lib/jvm/java-1.8-openjdk/lib" ]' Occlum.json)" && \ | ||||
|     echo "${new_json}" > Occlum.json | ||||
| } | ||||
| 
 | ||||
| build_sofa() { | ||||
|     # Copy JVM and JAR file into Occlum instance and build | ||||
|     rm -rf image | ||||
|     copy_bom -f ../sofaboot_jdk8.yaml --root image --include-dir /opt/occlum/etc/template | ||||
|     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-1.8-openjdk/jre/bin/java -Xmx512m -XX:-UseCompressedOops -XX:MaxMetaspaceSize=64m -Dos.name=Linux -jar /usr/lib/spring/${jar_file} & | ||||
| } | ||||
| 
 | ||||
| run_sofa | ||||
							
								
								
									
										9
									
								
								demos/sofaboot/sofaboot_jdk8.yaml
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										9
									
								
								demos/sofaboot/sofaboot_jdk8.yaml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| includes:  | ||||
|   - base.yaml | ||||
|   - java-8-openjdk.yaml | ||||
| targets:  | ||||
|   # copy sofaboot jar | ||||
|   - target: /usr/lib/spring | ||||
|     copy:  | ||||
|       - files:  | ||||
|         - ../sofa-boot-guides/sofaboot-sample-standard/target/boot/sofaboot-sample-standard-web-0.0.1-SNAPSHOT-executable.jar | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user