[demos] Fix golang webserver build error
This commit is contained in:
		
							parent
							
								
									9db48c3c5b
								
							
						
					
					
						commit
						11fffa6039
					
				
							
								
								
									
										3
									
								
								.github/workflows/demo_test.yml
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										3
									
								
								.github/workflows/demo_test.yml
									
									
									
									
										vendored
									
									
								
							| @ -82,8 +82,7 @@ jobs: | |||||||
|       run: docker exec ${{ github.job }} bash -c "cd /root/occlum/tools/toolchains/golang && ./build.sh go1.18.4_for_occlum && cd /root/occlum/demos/golang/go_sqlite/ && SGX_MODE=SIM ./run_go_sqlite_demo.sh" |       run: docker exec ${{ github.job }} bash -c "cd /root/occlum/tools/toolchains/golang && ./build.sh go1.18.4_for_occlum && cd /root/occlum/demos/golang/go_sqlite/ && SGX_MODE=SIM ./run_go_sqlite_demo.sh" | ||||||
| 
 | 
 | ||||||
|     - name: Go Server set up and run |     - name: Go Server set up and run | ||||||
|       run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/golang/web_server && occlum-go mod init web_server && occlum-go get -u -v github.com/gin-gonic/gin; |       run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/golang/web_server && ./build.sh; | ||||||
|             occlum-go build -o web_server ./web_server.go; |  | ||||||
|             SGX_MODE=SIM ./run_golang_on_occlum.sh" & |             SGX_MODE=SIM ./run_golang_on_occlum.sh" & | ||||||
| 
 | 
 | ||||||
|     - name: Set up Golang grpc pingpong test |     - name: Set up Golang grpc pingpong test | ||||||
|  | |||||||
							
								
								
									
										3
									
								
								.github/workflows/hw_mode_test.yml
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										3
									
								
								.github/workflows/hw_mode_test.yml
									
									
									
									
										vendored
									
									
								
							| @ -142,8 +142,7 @@ jobs: | |||||||
| 
 | 
 | ||||||
|     - name: Go server set up and run |     - name: Go server set up and run | ||||||
|       run: docker exec ${{ env.CONTAINER_NAME }} bash -c "export GO111MODULE=on; |       run: docker exec ${{ env.CONTAINER_NAME }} bash -c "export GO111MODULE=on; | ||||||
|             cd /root/occlum/demos/golang/web_server && occlum-go mod init web_server && occlum-go get -u -v github.com/gin-gonic/gin; |             cd /root/occlum/demos/golang/web_server && ./build.sh; | ||||||
|             occlum-go build -o web_server ./web_server.go; |  | ||||||
|             ./run_golang_on_occlum.sh" & |             ./run_golang_on_occlum.sh" & | ||||||
| 
 | 
 | ||||||
|     - name: Set up Golang grpc pingpong test |     - name: Set up Golang grpc pingpong test | ||||||
|  | |||||||
| @ -2,24 +2,18 @@ | |||||||
| 
 | 
 | ||||||
| This project demonstrates how Occlum enables [Golang](https://golang.org) programs running in SGX enclaves, the demo program is a HTTP web server based on a widely used web framework([Gin](https://gin-gonic.com)) for Go. | This project demonstrates how Occlum enables [Golang](https://golang.org) programs running in SGX enclaves, the demo program is a HTTP web server based on a widely used web framework([Gin](https://gin-gonic.com)) for Go. | ||||||
| 
 | 
 | ||||||
| Step 1: Install Gin with `occlum-go`, it may take a few minutes | Step 1: Install Gin and build Golang web server with `occlum-go` | ||||||
| ``` | ``` | ||||||
| occlum-go mod init web_server && \ | ./build.sh | ||||||
| occlum-go get -u -v github.com/gin-gonic/gin |  | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| Step 2: Build the Golang web server using the Occlum Golang toolchain(i.e., `occlum-go`) | Step 2: You can run the web server demo on Occlum via | ||||||
| ``` |  | ||||||
| occlum-go build -o web_server ./web_server.go |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| Step 3: You can run the web server demo on Occlum via |  | ||||||
| ``` | ``` | ||||||
| ./run_golang_on_occlum.sh | ./run_golang_on_occlum.sh | ||||||
| ``` | ``` | ||||||
| The HTTP web server should now start to listen on port 8090 and serve HTTP requests. | The HTTP web server should now start to listen on port 8090 and serve HTTP requests. | ||||||
| 
 | 
 | ||||||
| Step 4: To check whether the HTTP server works, run | Step 3: To check whether the HTTP server works, run | ||||||
| ``` | ``` | ||||||
| curl http://127.0.0.1:8090/ping | curl http://127.0.0.1:8090/ping | ||||||
| ``` | ``` | ||||||
|  | |||||||
							
								
								
									
										10
									
								
								demos/golang/web_server/build.sh
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										10
									
								
								demos/golang/web_server/build.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,10 @@ | |||||||
|  | #!/bin/bash | ||||||
|  | set -e | ||||||
|  | 
 | ||||||
|  | rm -f go.mod | ||||||
|  | occlum-go mod init web_server | ||||||
|  | occlum-go mod tidy | ||||||
|  | occlum-go get -u -v github.com/gin-gonic/gin | ||||||
|  | occlum-go get -u -v golang.org/x/crypto@v0.23.0 | ||||||
|  | 
 | ||||||
|  | occlum-go build -o web_server ./web_server.go | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user