spa-server靜態(tài) web 頁面托管服務(wù)
本軟件是用來創(chuàng)建一個托管靜態(tài)web頁面的服務(wù),目標是使單頁應用部署簡便、開銷少、性能高。
- 基于 Hyper 和 warp 構(gòu)建。
- SSL 基于 Rustls。
- 服務(wù)器端緩存、客戶端緩存(Cache-Content)、Gzip壓縮。
- SPA 版本管理, 僅需要一個 http 請求就能實現(xiàn)版本回滾和更新。
- 支持熱更新(Mac and Linux)。
- 支持 CORS 跨域
- http/https 同時服務(wù)(http 也可返回 redirect https)。
- 支持 Docker 鏡像(壓縮后大小:32M)
服務(wù)跑起來
配置文件說明: config.release.conf.
可以通過修改環(huán)境變量 SPA_CONFIG=${config_path}, 來更改配置文件地址。
通過源碼
git clone [email protected]:timzaak/spa-server.git cd spa-server git submodule init && git submodule update cp config.release.conf config.conf # please remember to change `file_dir` in config.conf cargo run --bin spa-server
通過鏡像
docker run -d -p 80 -p 443 -v $HOST_VOLUME:/data -v $CONFIG:/config.conf timzaak/spa-server:latest
如何部署靜態(tài)文件
當服務(wù)跑起來后,可將 SPA 文件夾復制到 admin server 指定文件夾, (api doc).
scp $SPA_DIRECTORY user@ip:$(curl "http://$ADMIN_SERVER/upload/path?domain=$DOMAIN" -H "Authorization: Bearer $TOKEN")
等文件傳輸完畢, 發(fā)起 HTTP 請求更新 SPA 版本。
curl "http://$ADMIN_SERVER/update_version?domain=$DOMAIN&version=$VERSION" -H "Authorization: Bearer $TOKEN"
至此,部署完畢!
評論
圖片
表情
