我有兩個要使用 Google Cloud App Engine 部署的應用程式。
其中之一是反應前端,我想通過
uj5u.com熱心網友回復:
你走在正確的道路上。您正在使用微服務架構,該架構基本上將單個應用程式部署為單個專案下的部分(服務)。
您的前端服務似乎是您的默認服務,因此您不需要它的服務名稱。每個 GAE 應用程式都需要一個默認服務。
重命名
react.yaml為app.yaml(因為它將是您的默認服務)并將內容更新為runtime: nodejs16 env: standard handlers: - url: /static static_dir: static secure: always - url: /.* script: auto secure: always還要將您的名稱重命名
api.yaml為,backend.yaml因為這就是您所說的服務(不確定這是否需要,但我這樣做是為了輕松跟蹤控制我的服務的內容)。將檔案內容更新為service: backend runtime: python37 entrypoint: gunicorn -b :$PORT videoo.wsgi env: standard handlers: - url: /.* script: auto secure: always您需要一個dispatch.yaml檔案來將流量路由到不同的服務。就像是
dispatch:
# Send all api traffic to the backend service.
- url: "api.videoo.io/*"
service: backend
# Send all other traffic to the default (frontend).
- url: "*/*"
service: default
- 最后一步是,在部署期間,除了 dispatch.yaml 檔案之外,您還將部署 2 個服務。dispatch.yaml 檔案必須在您的專案根檔案夾中
gcloud app deploy app.yaml dispatch.yaml <path_to_backend.yaml>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/472119.html
