在google应用程序引擎上部署带环回的Angular 10应用程序
我是Angular的新手,构建Angular 10应用程序,以环回作为后端,用MySQL数据库处理所有crud函数。我的Angular应用程序正在localhost:4200和localhost:3000上运行。现在我想在谷歌应用程序引擎标准环境中部署我的应用程序。我能够部署angular应用程序,angular运行良好。但是如何在谷歌应用程序引擎上连接环回 我运行此命令在根文件夹中构建我的应用程序在google应用程序引擎上部署带环回的Angular 10应用程序,angular,google-app-engine,loopback,Angular,Google App Engine,Loopback,我是Angular的新手,构建Angular 10应用程序,以环回作为后端,用MySQL数据库处理所有crud函数。我的Angular应用程序正在localhost:4200和localhost:3000上运行。现在我想在谷歌应用程序引擎标准环境中部署我的应用程序。我能够部署angular应用程序,angular运行良好。但是如何在谷歌应用程序引擎上连接环回 我运行此命令在根文件夹中构建我的应用程序 ng build --prod 这创建了dist文件夹,我已将其与app.yml文件一
ng build --prod
这创建了dist文件夹,我已将其与app.yml文件一起部署。
app.yml文件的内容
runtime: python37
manual_scaling:
instances: 5
service: angular
handlers:
- url: /
static_files: my-app/index.html
upload: my-app/index.html
- url: /
static_dir: my-app
您必须在另一个应用程序引擎服务上部署后端代码,并且必须将该服务URL用作应用程序中的API URL 例如:后端部署在API服务上,其URL类似https://api-dot-{project id}.{region}.appspot.com然后将此URL用作API URL App.yaml文件应如下所示:
runtime: python37
service: api
runtime_config:
document_root: public // web accessible path here
whitelist_functions: shell_exec
env_variables:
您必须在GAE上将Nodejs后端部署为不同的服务,并在该服务URL上调用角度环回,使用下面的app.yaml config部署Nodejs
#app.yaml
runtime: nodejs
manual_scaling:
instances: 5
service: angular
env: flex
gcloud应用程序部署
这将创建类似以下内容的URL
https://angular-dot-{project id}.{region}.appspot.com
然后在应用程序中查找“app.component.ts”文件,通常位于src/app中/
并更改以下配置
LoopBackConfig.setBaseURL('https://angular-dot-{project-id}.{region}.appspot.com');
然后通过以下方式创建angular应用程序的生产配置:
ng build --prod
它将创建一个dist目录,
创建app.yaml文件以将其部署到云上,如下所示
角度应用程序App.yaml
#app.yaml
runtime: python37
manual_scaling:
instances: 5
service: ang-loop
handlers:
- url: /
static_files: my-app/index.html
upload: my-app/index.html
- url: /
static_dir: my-app
将app.yaml文件移动到dist目录中
然后使用(在dist目录中)将其部署到google云上
这应该管用 你将不得不主持你的后端太,如果它是一个nodejs后端也许这可以帮助你分享更多的细节,你的后端?
gcloud app deploy