What is the equivalent of `appcfg.py -E` in `gcloud app deploy`? - google-app-engine

This answer says that appcfg.py -E allows me to set secrets on deploy and this answer says that appcfg.py will go away. Is there a way for me to set environment variables on command line when deploying an AppEngine app using gcloud app deploy?

You can't for deployments. Instead, you can always specify your environment variables in the app.yaml file.

Related

Golang Cloud SDK - gcloud app deploy cannot find import package

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
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.

Deploying endpoints app into appengine with appcfg.py

The documentation describes how to deploy endpoints application with gcloud tool but is it possible to deploy the app with appcfg.py?
What I'd like is to use this command:
appcfg.py update [YOUR_APP_DIR] -A [YOUR_PROJECT_ID] -V [YOUR_VERSION_ID]
And don't have to edit the app.yaml file to set a new value for ENDPOINTS_SERVICE_VERSION variable every time I need to deploy a new version.
If I understand correctly YOUR_VERSION_ID application version is not the same as ENDPOINTS_SERVICE_VERSION but where this difference is important?

How to update queues with gcloud?

I previously was using appcfg.py to deploy my (python) applications on Google AppEngine, but I recently switched to the gcloud command.
For updating the queues, I was doing :
/opt/google/google_appengine/appcfg.py -A project-id update_queues .
But now with ‘gcloud‘ I don't know how I can do that?
For information, here's how I deploy a new version now :
gcloud app deploy --project project-id app.yaml
Thank you :)
The cloud sdk deploy command supports multiple config files index.yaml, queue.yaml, dispatch.yaml, dos.yaml, cron.yaml
gcloud app deploy [DEPLOYABLES …]
[DEPLOYABLES …]
The yaml files for the services or configurations you want to deploy. If not given, defaults to app.yaml in the current directory. If that is not found, attempts to automatically generate necessary configuration files (such as app.yaml) in the current directory.
https://cloud.google.com/sdk/gcloud/reference/app/deploy
So:
gcloud app deploy app.yaml queue.yaml

app.yaml to send params to Dockerfile

I am deploying a binary on Google cloud flexible app engine for two different services. So I have {app-service1.yaml, Dockerfile-service1} and {app-service2.yaml, Dockerfile-service2}. And use "gcloud app deploy" command to deploy them.
Is it possible to send a param from app-service[1|2].yaml to a single Dockerfile, so that I can maintain only one Dockerfile?
I tried two things but they didn't work with "gcloud deploy" command:
"entrypoint:" in app.yaml -- It does not override what is set in CMD in Dockerfile.
"env_variables:" in app.yaml -- Dockerfile's ENV or ARG do not see any variables defined in env_variables:.
There's currently no way (I can think of) to pass parameters into the docker build process while using gcloud app deploy. If the dockerfiles you're using are similar, you may want to consider creating a base docker file, building a base image, and then sending it to gcr.io. Then you can extend the base image with your other Dockerfile(s).
Hope this helps!

Difference between 'goapp deploy' and 'appcf.py' to deploy my app on Google App Engine?

I don't understand the difference between
goapp deploy -application <YOUR_PROJECT_ID> myapp/
and
appcfg.py -A <YOUR_PROJECT_ID_> -V v1 update myapp/
when trying to deploy my app in google app engine. Can somebody enlighten me please?
Documented in Uploading, Downloading, and Managing a Go App:
goapp deploy wraps the appcfg.py python tool provided in the SDK. You can also invoke this tool directly if you need greater control over the deployment.
goapp deploy is equivalent to appcfg.py update myapp/.
These commands get application ID and other configuration from app.yaml automatically. You can use -application param of goapp, or -A of appcfg.py to override the application ID.
So goapp deploy calls appcfg.py under the hood, it is a convenient method to hide appcfg.py.
goapp deploy -application <YOUR_PROJECT_ID> myapp/
Deploys the application located in the myapp folder. Configuration will be read from the app.yaml file that must be at myapp/app.yaml. The command also overrides the application ID (if present in app.yaml), and <YOUR_PROJECT_ID> will be used instead.
appcfg.py -A <YOUR_PROJECT_ID> -V v1 update myapp/
This also deploys the application, but the -V overrides the version that may be present in myapp/app.yaml, and will use the version v1. -A is used to override the ID from app.yaml, will be <YOUR_PROJECT_ID> in this case.
goapp is a general tool for the whole Go-on-App-Engine workflow from build to deployment; you can use the same tool to install dependences (get), build your app, run locally (serve) and then deploy it (as well as run tests, format code, etc).
Some of these wrap other tools: goapp fmt probably just wraps gofmt, whilst goapp deploy just wraps appcfg.py update (see docs)

Resources