9
votes

according to the official documentation for Google App Engine Standard environment (Go API) the "preferred tooling to deploy a project" is now the Cloud SDK and so we moved to gcloud from goapp.

We are unable to deploy Go projects to GAE because all the sub-packages of every given project can't be found at "deploy time". The typical folder structure that we have been using for every GAE project was as follows:

-project-name
--app.yaml
--main.go
--assets
---package1
---package2

When global libraries were put in the system GOPATH everything worked smoothly.

Running gcloud app deploy we now get this:

You are about to deploy the following services:
 - yourproject/default/123456789 (from [/Path/to/app.yaml])
     Deploying to URL: [https://yourproject.appspot.com]

Do you want to continue (Y/n)?  Y

Beginning deployment of service [default]...
ERROR: (gcloud.app.deploy) Staging command [/path/to/yourproject/app.yaml /var/folders/b6/5ydn0wdn64jd32sxzzz48b7c0000gn/T/tmpbd4oiG] failed with return code [1].

------------------------------------ STDOUT ------------------------------------
------------------------------------ STDERR ------------------------------------
2017/03/24 10:25:58 failed analyzing /path/to/yourproject: cannot find package "yourpackage" in any of:
        ($GOROOT not set)
        /path/to/gopath/src/yourpackage (from $GOPATH)
GOPATH: /path/to/gopath
--------------------------------------------------------------------------------

while dev_appserver.py works perfectly keeping the same folder structure.

Did we miss something? How can we deploy to Google App Engine Standard environment using gcloud?

If the project structure needs to be changed: how? Is there official documentation about it?

Thanks in advance,

Edit -- Further infos:

Luigi-Mac-Pro:path/to/yourproject distudio$ gcloud version
Google Cloud SDK 148.0.0
app-engine-go 
app-engine-go-darwin-x86_64 1.9.50
app-engine-python 1.9.50
bq 2.0.24
bq-nix 2.0.24
core 2017.03.17
core-nix 2016.11.07
gcloud 
gcloud-deps 2017.03.17
gcloud-deps-darwin-x86_64 2017.02.21
gsutil 4.23
gsutil-nix 4.22
1

1 Answers

5
votes

Google recommends keeping your dependencies outside of the app directory, and using GOPATH to refer them. In your case, that would mean doing the following:

-project-name
--app.yaml
--main.go

where main.go contains

import (
    "package1"
    "package2"
)

And somewhere else:

-my_packages
--src
---package1
---package2

And then set GOPATH environment variable to path/to/my_packages prior to running dev_appserver and gcloud app deploy.

For the future

We are working out the long term solution for properly vendoring packages inside your app directory – likely using Go's future native package manager. I'm sorry to say that we don't have a good way of supporting sub-packages for gcloud app deploy. This was an unfortunate side effect of compatibility with the App Engine Flexible environment.