我已经将我的应用程序版本部署到GAE,但现在我无法部署更新的版本。
当我尝试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
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设置为project-root。我的GOROOT是空的。