Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将Angular 7项目部署到Google云_Javascript_Angular7_Gcloud - Fatal编程技术网

Javascript 如何将Angular 7项目部署到Google云

Javascript 如何将Angular 7项目部署到Google云,javascript,angular7,gcloud,Javascript,Angular7,Gcloud,我已经构建了Angular 7应用程序,当我从本地mac或远程centos服务器执行ng serve命令时,该应用程序运行良好 这个应用程序使用的是访问MySQL数据库的php文件,这两个数据库都是在我的谷歌云上提供的 现在,在执行gcloud app deploy之后,我在屏幕上看到的最后一条消息是: nebula@0.0.0启动/应用程序 ng发球 sh:1:ng:未找到 我死在水里了 我尝试了很多不同版本的app.yaml和cloudbuild.yaml文件,我觉得我什么都没学到 我也尝试

我已经构建了Angular 7应用程序,当我从本地mac或远程centos服务器执行
ng serve
命令时,该应用程序运行良好

这个应用程序使用的是访问MySQL数据库的
php
文件,这两个数据库都是在我的谷歌云上提供的

现在,在执行
gcloud app deploy
之后,我在屏幕上看到的最后一条消息是:

nebula@0.0.0启动/应用程序 ng发球

sh:1:ng:未找到

我死在水里了

我尝试了很多不同版本的
app.yaml
cloudbuild.yaml
文件,我觉得我什么都没学到

我也尝试过同样的方法,从非常基本的“英雄”应用程序开始,得到了同样的问题

i、 e

ng新xxx cd xxx npm安装 ng发球

然后我在浏览器中看到默认的Heros屏幕

然后我创建这个
app.yaml
文件

runtime: nodejs
env: flex

manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10


service: 
  xxx
然后,我尝试使用以下方法进行部署:

gcloud应用程序部署

当这一切结束时,我得到了信息

已将服务[xxx]部署到[

当我转到该url时,我得到:

错误:服务器错误

服务器遇到错误,无法完成您的请求。 请在30秒后重试

此运行的日志文件为:

    gcloud app logs tail -s xxx
    Waiting for new log entries...
    2019-05-04 15:27:35 xxx[20190504t102436]  "GET / HTTP/1.1" 404
    2019-05-04 15:27:35 xxx[20190504t102436]  "GET /favicon.ico HTTP/1.1" 404
    2019-05-04 15:28:56 xxx[20190504t102436]  "GET / HTTP/1.1" 404
    2019-05-04 15:32:45 xxx[prod]  "GET / HTTP/1.1" 404
    2019-05-04 15:32:50 xxx[prod]  "GET / HTTP/1.1" 404
    2019-05-04 15:33:06 xxx[prod]  "GET / HTTP/1.1" 404
    2019-05-04 15:33:10 xxx[prod]  "GET /run HTTP/1.1" 404
    2019-05-04 15:33:10 xxx[prod]  "GET /favicon.ico HTTP/1.1" 404
    2019-05-04 15:33:16 xxx[prod]  "GET /run HTTP/1.1" 404
    2019-05-04 15:33:16 xxx[prod]  "GET / HTTP/1.1" 404
    2019-05-04 15:33:19 xxx[prod]  "GET /login HTTP/1.1" 404
    2019-05-04 15:33:19 xxx[prod]  "GET /favicon.ico HTTP/1.1" 404
    2019-05-04 15:40:43 xxx[prod]  "GET /login HTTP/1.1" 404
    2019-05-04 15:40:46 xxx[prod]  "GET /login HTTP/1.1" 404
    2019-05-04 15:40:50 xxx[prod]  "GET /login HTTP/1.1" 404
    2019-05-04 15:40:50 xxx[prod]  "GET / HTTP/1.1" 404
    2019-05-04 15:40:53 xxx[prod]  "GET / HTTP/1.1" 404
    2019-05-04 16:01:50 xxx[20190504t105955]  "GET / HTTP/1.1" 500
    2019-05-04 16:01:51 xxx[20190504t105955]  /bin/sh: 1: ng: not found
    2019-05-04 16:06:19 xxx[20190504t105955]  "GET / HTTP/1.1" 500
    2019-05-04 16:06:20 xxx[20190504t105955]  /bin/sh: 1: ng: not found

我的问题是,有人能提供一个简单的例子,说明应用程序在谷歌云中运行的过程吗?

项目创建后,在GitHub上发布您的项目。 在GitHub应用程序上,您必须立即安装Google Cloud Build,因为它需要访问您的存储库。 您还必须为新应用程序创建一个谷歌云项目,并启用云构建和云应用引擎

请参阅此处了解更多详细信息:-

项目创建后,在GitHub上发布您的项目。 在GitHub应用程序上,您必须立即安装Google Cloud Build,因为它需要访问您的存储库。 您还必须为新应用程序创建一个谷歌云项目,并启用云构建和云应用引擎

请参阅此处了解更多详细信息:-

在部署带有PHP后端的Ng7应用程序时,我建议您使用两种不同的解决方案:

  • 使用CDN优化SPA以部署Ng应用程序(更改您的environment.ts以将其定向到AE端点。您将首先使用
    Ng build
    构建应用程序,然后部署工件,因此在生成的包中甚至不需要角度工具
  • 使用AppEngine部署后端

在部署带有PHP后端的Ng7应用程序时,我建议您使用两种不同的解决方案:

  • 使用CDN优化SPA以部署Ng应用程序(更改您的environment.ts以将其定向到AE端点。您将首先使用
    Ng build
    构建应用程序,然后部署工件,因此在生成的包中甚至不需要角度工具
  • 使用AppEngine部署后端

看来去firebase的建议是最有用的选择


我离我想去的地方更近了,现在我看到了很多有用的额外信息。

看来去firebase的建议是最有用的选择

我离我想去的地方更近了,现在我看到了很多有用的额外功能。

您可以部署一个SPA(如Angular),它具有类似的功能:

runtime: nodejs10
env_variables:
  NODE_ENV: production
handlers:
  - url: /
    static_files: dist/my-project/index.html
    upload: dist/my-project/index.html

  - url: /
    static_dir: dist/my-project
您需要预先使用
ng build--prod
在本地构建angular项目,否则您需要在package.json上设置
predeploy
命令,该命令将由
gcloud app deploy
(例如
predeploy:“npm run lint&&npm run build--prod--aot”
)调用。同样重要的是,您需要确保忽略
dist
文件夹之外的所有文件,并使用
.gcloudignore
文件。这将阻止google cloud上载这些文件

# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
#   $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore

# Node.js dependencies:
node_modules/
webpack.config.js
src/
tsconfig.json
readme.md
ssl/
tslint.json
LICENSE
.editorconfig
.dockerignore
.gitignore
包括所有这些文件

您可以部署SPA(如Angular),其类似于:

runtime: nodejs10
env_variables:
  NODE_ENV: production
handlers:
  - url: /
    static_files: dist/my-project/index.html
    upload: dist/my-project/index.html

  - url: /
    static_dir: dist/my-project
您需要预先使用
ng build--prod
在本地构建angular项目,否则您需要在package.json上设置
predeploy
命令,该命令将由
gcloud app deploy
(例如
predeploy:“npm run lint&&npm run build--prod--aot”
)调用。同样重要的是,您需要确保忽略
dist
文件夹之外的所有文件,并使用
.gcloudignore
文件。这将阻止google cloud上载这些文件

# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
#   $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore

# Node.js dependencies:
node_modules/
webpack.config.js
src/
tsconfig.json
readme.md
ssl/
tslint.json
LICENSE
.editorconfig
.dockerignore
.gitignore

包括所有这些文件

我感谢您的回复,并尝试遵循您的建议。这就是我遇到的问题。我尝试了该链接。但是,首先它假设我使用GitHub应用程序。虽然我有一个git帐户,但我不知道什么是GitHub应用程序。因此,现在我必须了解GitHub应用程序的所有信息。其次,示例参考ed使用Python。我不懂Python,我的项目是用Javascript编写的。因此,现在我必须学习另一种语言来将Python示例转换为Javascript示例。我只希望我能找到一个快速入门,以Angular Heros示例为例,将其作为Goggle应用程序运行。我感谢您的回复,并尝试遵循您的建议。t他是我遇到问题的地方。我尝试过这个链接。但是,首先它假设我使用GitHub应用程序。虽然我有一个git帐户,但我不知道什么是GitHub应用程序。所以现在我必须学习GitHub应用程序的所有知识。其次,引用的示例是Python。我不知道Python,我的项目是用Javascript编写的。所以现在我必须学习我只希望我能找到一个快速入门,以Angular Heros为例,将其作为Goggle应用程序运行。