I have already deployed a version of my app to GAE, but now I have trouble deploying a newer version.
When I try gcloud app deploy --version=VERSION
, I get a bunch of errors showing that remote build cannot find my import packages:
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
I have tried several suggestions wrt proper setting of the GOPATH, including running command as root, sudo -E, and setting a system-wide GOPATH, no luck so far. I get the same set of errors no matter if I deploy in Cloud Shell or run the command in my local setup. If I set a wrong GOPATH build fails before getting to the remote build stage. I have not changed the source code structure from the first deployment either.
I have spent lot's of time on this, and appreciate any help or advice. Thanks.
EDIT: Here is my app.yaml
runtime: go
env: flex
api_version: go1
env_variables:
APP_DATABASE_CONFIG: "{...}"
APP_CONFIG: "{...}"
Also running dev_appserver.py app.yaml
I get the following output:
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
...
It generally works fine except for that warning at the beginning. I don't know why it gives that warning despite my app.yaml configuration, but if it helps the first instance I deployed was a standard project (the Google demo project), and I deleted that instance later.
I am wondering where those GOROOT (/usr/local/go/) and GOPATH (/workspace/_gopath/) on the remote side come from? Are those the default settings? Also if it helps, those db and config packages shown in error messages are mine, and they are under project-root/src.
app.yaml is under project-root/src/web. My GOPATH is set to project-root. My GOROOT is empty.