Go+ Builder Online Deployment
Summary
Go+ Builder is a complex SPA (Single Page Application) with its own backend server. The optimization for static assets' distribution is important.
There may be 3 ways to archieve so:
- Deploy backend & frontend (pages and static assets) together on QVM, then apply full site accelaration (for both dynamic & static content)
- Deploy backend & frontend pages together on QVM, and static assets on OSS, then apply static content accelaration for static assets
- Deploy backend on QVM, frontend (pages and static assets) on Vercel (leveraging Vercel's default content accelaration)
Currently Goplus projects (like https://goplus.org) have existing dependencies on Vercel (and planning to put more sites on Vercel), but no direct dependencies on Content Delievery Network service. To keep as less external dependent types as possible, we gonna take the 3rd way.
Which means there will be 2 online domains for builder: builder.goplus.org & builder-api.goplus.org.
builder.goplus.orgpoints to a Vercel project "builder", which is built based onspx-gui/builder-api.goplus.orgpoints to a Go server on QVM, which is built based onspx-backend/
Details
Some details:
-
Static assets will be hosted under domain
builder.goplus.org(same with the HTML page) -
Widgets loader will be hosted under domain
builder.goplus.org(same with the HTML page) -
We configure
VITE_API_BASE_URLtohttps://builder-api.goplus.org/so that HTTP API requests go to the Go server. And CORS related headers are configured properly so the requests will not be rejected. -
It is possible for Vercel project to proxy API requests: they go through from
https://builder.goplus.com/api/footohttps://builder-api.goplus.com/foo, which means API requests may also benefit from Vercel network.This will not change the main design for deployment, so we discuss & implement it as a small detail.
PR Preview
Two possible ways:
- All in Qiniu PR Enviroment
- Backend in Qiniu PR Enviroment, frontend pages & assets on Vercel
The 1st way is preferred, cuz it's simpler. So we need to disable the Vercel PR preview behavior.
With #170: https://builder.goplus.org
TODOs after #170:
- [x] Update env config with online API server address
- [x] Update env config with online Casdoor information
- [x] API Proxy (#414)
- [x] Use branch
mainfor production deployment (branchdevis temporarily used) - [x] #254
- [x] #220
done