我已经将应用程序的一个版本部署到GAE,但是现在我无法部署一个较新的版本。当我尝试时gcloud app deploy --version=VERSION,出现一堆错误,表明远程版本找不到我的导入包:
gcloud app deploy --version=VERSION
Beginning deployment of service [default]... Building and pushing image for service [default] Some files were skipped. Pass `--verbosity=info` to see which ones. You may also view the gcloud log file, found at [/home/****/.config/gcloud/logs/2018.04.08/***.log]. Started cloud build [***]. To see logs in the Cloud Console: https://console.cloud.google.com/gcr/builds/****?project=** ------------- REMOTE BUILD OUTPUT -------------------------------------------- starting build "****" FETCHSOURCE Fetching storage object: gs://staging.****.appspot.com/us.gcr.io/****/appengine/default.20180408t040210:latest#**** Copying gs://staging.****.appspot.com/us.gcr.io/****/appengine/default.***:latest#***... / [1 files][ 6.9 MiB/ 6.9 MiB] Operation completed over 1 objects/6.9 MiB. BUILD Starting Step #0 Step #0: Pulling image: gcr.io/gcp-runtimes/go1builder@sha256:**** Step #0: sha256:***: Pulling from gcp-runtimes/go1-builder Step #0: Digest: sha256:*** Step #0: Status: Downloaded newer image for gcr.io/gcp-runtimes/go1-builder@sha256:*** Step #0: main.go:5:2: cannot find package "config" in any of: Step #0: /usr/local/go/src/config (from $GOROOT) Step #0: /workspace/_gopath/src/config (from $GOPATH) Step #0: main.go:6:2: cannot find package "db" in any of: Step #0: /usr/local/go/src/db (from $GOROOT) Step #0: /workspace/_gopath/src/db (from $GOPATH) ... Finished Step #0 ERROR ERROR: build step 0 "gcr.io/gcp-runtimes/go1builder@sha256:***" failed: exit status 1 ------------------------------------------------------------------------------- ERROR: (gcloud.app.deploy) Cloud build failed. Check logs at https://console.cloud.google.com/gcr/builds/***?project=*** Failure status: UNKNOWN: Error Response: [2] Build failed; check build logs for details
我已经尝试过一些对GOPATH进行正确设置的建议,包括以root身份运行命令,sudo -E以及设置系统范围的GOPATH,到目前为止还算不错。无论我部署在Cloud Shell中还是在本地设置中运行命令,我都会遇到相同的错误集。如果我设置了错误的GOPATH,则在进入远程构建阶段之前,构建会失败。我也没有从第一次部署中更改源代码结构。
我花了很多时间在此上,并感谢任何帮助或建议。谢谢。
编辑: 这是我的app.yaml
runtime: go env: flex api_version: go1 env_variables: APP_DATABASE_CONFIG: "{...}" APP_CONFIG: "{...}"
同样运行,dev_appserver.py app.yaml我得到以下输出:dev_appserver.py app.yaml
dev_appserver.py app.yaml
INFO 2018-04-11 05:20:51,040 application_configuration.py:506] No version specified. Generated version id: 20180411t052051 WARNING 2018-04-11 05:20:51,040 application_configuration.py:163] The Managed VMs runtime is deprecated, please consider migrating your application to use the Flexible runtime. See https://cloud.google.com/appengine/docs/flexible/python/migrating for more details. INFO 2018-04-11 05:20:51,040 devappserver2.py:105] Skipping SDK update check. INFO 2018-04-11 05:20:51,102 api_server.py:265] Starting API server at: http://localhost:46211 INFO 2018-04-11 05:21:16,233 dispatcher.py:255] Starting module "default" running at: http://localhost:8080 INFO 2018-04-11 05:21:16,234 admin_server.py:152] Starting admin server at: http://localhost:8000 ...
除了开头的警告之外,它通常可以正常工作。尽管配置了app.yaml,但我不知道为什么它会发出警告,但是如果它帮助我部署的第一个实例是一个标准项目(Google演示项目),后来又删除了该实例。
我想知道远端的那些GOROOT(/ usr / local / go /)和GOPATH(/ workspace / _gopath /)来自何处?这些是默认设置吗?同样,如果有帮助,错误消息中显示的那些db和config软件包是我的,它们位于project-root / src下。
app.yaml位于project-root / src / web下。我的GOPATH设置为项目根目录。我的GOROOT是空的。
您的Flex app.yaml文件不应包含
api_version: go1
您可以完全删除该行。只有App Engine标准版才需要。
这是一个示例App Engine Flexible app.yaml文件。有关可在Flex app.yaml文件中配置的内容的参考,请参阅文档。