[demos] Fix golang webserver build error

This commit is contained in:
Qi Zheng 2024-06-13 09:53:39 +08:00 committed by volcano
parent 9db48c3c5b
commit 11fffa6039
4 changed files with 16 additions and 14 deletions

@ -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

@ -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

@ -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
```

@ -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