diff --git a/.github/workflows/demo_test.yml b/.github/workflows/demo_test.yml index f46fad18..6d11a873 100644 --- a/.github/workflows/demo_test.yml +++ b/.github/workflows/demo_test.yml @@ -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" - 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; - occlum-go build -o web_server ./web_server.go; + run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/golang/web_server && ./build.sh; SGX_MODE=SIM ./run_golang_on_occlum.sh" & - name: Set up Golang grpc pingpong test diff --git a/.github/workflows/hw_mode_test.yml b/.github/workflows/hw_mode_test.yml index 427a4a1f..8d179423 100644 --- a/.github/workflows/hw_mode_test.yml +++ b/.github/workflows/hw_mode_test.yml @@ -142,8 +142,7 @@ jobs: - name: Go server set up and run 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; - occlum-go build -o web_server ./web_server.go; + cd /root/occlum/demos/golang/web_server && ./build.sh; ./run_golang_on_occlum.sh" & - name: Set up Golang grpc pingpong test diff --git a/demos/golang/web_server/README.md b/demos/golang/web_server/README.md index 3ca5c836..9e5f4a13 100644 --- a/demos/golang/web_server/README.md +++ b/demos/golang/web_server/README.md @@ -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. -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 && \ -occlum-go get -u -v github.com/gin-gonic/gin +./build.sh ``` -Step 2: Build the Golang web server using the Occlum Golang toolchain(i.e., `occlum-go`) -``` -occlum-go build -o web_server ./web_server.go -``` - -Step 3: You can run the web server demo on Occlum via +Step 2: You can run the web server demo on Occlum via ``` ./run_golang_on_occlum.sh ``` 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 ``` diff --git a/demos/golang/web_server/build.sh b/demos/golang/web_server/build.sh new file mode 100755 index 00000000..b3b9e282 --- /dev/null +++ b/demos/golang/web_server/build.sh @@ -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