简体   繁体   English

如何在Google App Engine中构建API和前端应用程序?

[英]how should I architecture an API and front app in Google App Engine?

I'm developing my first node.js app deploying to GAE. 我正在开发第一个部署到GAE的node.js应用程序。

It'll be organized as an API service and a front-end web app developed with Next.js 它将作为API服务和使用Next.js开发的前端网络应用进行组织

I'm looking at this architecture, and, although I have the app separated in two repositories I could have one merged repo to create two different microservices: 我正在研究这种体系结构,尽管我将应用程序分为两个存储库,但我可以有一个合并的存储库来创建两个不同的微服务:

https://medium.com/this-dot-labs/node-js-microservices-on-google-app-engine-b1193497fb4b https://medium.com/this-dot-labs/node-js-microservices-on-google-app-engine-b1193497fb4b

For me, it seems overwork creating a new repo to merge them and deploy (doesn't it break one of the basic ideas of microservices to make isolated deploys?) 对我来说,创建一个新的仓库来合并它们并进行部署似乎太劳累了(难道不打破微服务的基本思想之一来进行隔离的部署吗?)

I have to discourage this because we need SEO in some of the parts, and We should use Next.js (or similar): 我不得不劝阻这是因为我们在某些部分需要SEO,并且我们应该使用Next.js(或类似的东西):

https://cloud.google.com/storage/docs/hosting-static-website https://cloud.google.com/storage/docs/hosting-static-website

Another idea I've been working on is... create different GAE projects for front and API to deploy independently. 我一直在努力的另一个想法是...为前端和API创建不同的GAE项目以独立部署。 For me, it seems like the best option, but I would like to know your opinion as GAE experts. 对我来说,这似乎是最好的选择,但我想了解您作为GAE专家的意见。

Which one should I use? 我应该使用哪一个?

Thanks! 谢谢!

GAE doesn't care how is the code to be deployed into the services mapped to one or more VCS repositories (or no repositories at all). GAE不在乎将代码部署到服务中的方式如何映射到一个或多个VCS存储库(或根本没有存储库)。 That's entirely up to you. 这完全取决于您。

With a single repository you may encounter difficulties deploying from CI/CD pipelines - for example unnecessary deployments to one service when only the other one is changed. 使用单个存储库,您可能会遇到从CI / CD管道进行部署的困难-例如,当仅更改另一项服务时,将不必要的部署部署到一项服务。

Many examples out there focus on applications rather than services, but those are nothing more than the default services of those applications. 那里的许多示例都集中在应用程序而不是服务上,但是这些仅是这些应用程序的默认服务。 Personally I like keeping the code for different services in separate directories, see the image captured in Can a default service/module in a Google App Engine app be a sibling of a non-default one in terms of folder structure? 就我个人而言,我喜欢将不同服务的代码保存在单独的目录中,请参阅中的图像。就文件夹结构而言,Google App Engine应用程序中的默认服务/模块可以成为非默认服务/模块的兄弟吗? (it's no longer present on the updated documentation page). (在更新的文档页面上不再存在)。 This also allows for easy mapping to multiple, separate VCS repositories 这还允许轻松映射到多个单独的VCS存储库

As for multiple projects vs multiple services, this might be of help: Advantages of implementing CI/CD environments at GAE project/app level vs service/module level? 对于多个项目还是多个服务,这可能会有帮助: 在GAE项目/应用程序级别与服务/模块级别上实现CI / CD环境的优势?

The static website link you mentioned isn't part of GAE, it's part of GCS - a different GCP product. 您提到的静态网站链接不是GAE的一部分,而是GCS的一部分-GCS的另一种产品。 It's fine to use by itself - for a static website, but it might be difficult/impossible to: 可以单独使用-对于静态网站,但可能难以/不可能:

  • communicate between a service running on it and one running on GAE - if you need that 在运行在其上的服务与运行在GAE上的服务之间进行通信-如果需要的话
  • make the 2 services appear as one (for example serve under the same custom domain name) 使这两项服务显示为一项(例如,以相同的自定义域名提供服务)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google App Engine API +静态架构 - Google App Engine API + static architecture Google App Engine - 前端和后端Web开发 - Google App Engine - Front and Backend Web Development 如何在 Google App Engine 上为后端 api 运行 Angular 通用应用程序和单独的节点应用程序? - How do I run an Angular Universal app and separate node app for backend api on Google App Engine? 如何让 App Engine 前端服务使用来自不同 App Engine 服务的 API - How to have App Engine front-end service use API from different App Engine service 如何在 Google App Engine 中发布 Nestjs api? - How to publish Nestjs api in Google App Engine? 在Google App Engine上运行Bottle(后端)+ Nodejs(前端) - Running Bottle (back end) + Nodejs (front end) on Google App Engine Express API可在localhost上访问,但不能在Google App Engine上访问 - Express API accessible on localhost but not on Google App Engine 如何将 socket.io 部署到 Google App Engine? - How do I deploy socket.io to Google App Engine? 如何在Google Compute Engine上部署节点应用程序? - How do I deploy a node app on Google Compute Engine? 如何将 Node HTTP/2 服务器部署到 Google App Engine? - How can I deploy a Node HTTP/2 server to Google App Engine?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM