builder icon indicating copy to clipboard operation
builder copied to clipboard

Go+ Builder Online Deployment

Open nighca opened this issue 1 year ago • 1 comments

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:

  1. Deploy backend & frontend (pages and static assets) together on QVM, then apply full site accelaration (for both dynamic & static content)
  2. Deploy backend & frontend pages together on QVM, and static assets on OSS, then apply static content accelaration for static assets
  3. 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.org points to a Vercel project "builder", which is built based on spx-gui/
  • builder-api.goplus.org points to a Go server on QVM, which is built based on spx-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_URL to https://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/foo to https://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:

  1. All in Qiniu PR Enviroment
  2. 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.

nighca avatar Mar 11 '24 08:03 nighca

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 main for production deployment (branch dev is temporarily used)
  • [x] #254
  • [x] #220

nighca avatar Mar 11 '24 15:03 nighca

done

aofei avatar May 30 '24 02:05 aofei