I used to configure the application name in app.yaml. But I just re-read the latest docs, and they say:
The recommended approach is to remove the application element from your app.yaml file and instead, use a command-line flag to specify your application ID:
To use the gcloud app deploy command, you must specify the --project flag:
gcloud app deploy --project [YOUR_PROJECT_ID]
To use the appcfg.py update command, you specify the -A flag:
appcfg.py update -A [YOUR_PROJECT_ID]
But what about dev_appserver.py? How do I configure it with the project name?
dev_appserver.py also supports the -A flag to set the application id.
From the output for dev_appserver.py -h:
-A APP_ID, --application APP_ID
Set the application, overriding the application value
from the app.yaml file. (default: None)
Related
Trying to run gcloud init to initialize the Google App Engine Engine SDK by typing ./google-cloud-sdk/bin/gcloud init but it showed: no such file or directory or command not found. Is something wrong with my PATH? My path is:
/Users/AnneLutz/Documents/google-cloud-sdk\
If you typing ./google-cloud-sdk/bin/gcloud init and you installed Cloud SDK in /Users/AnneLutz/Documents/google-cloud-sdk, then your current directory should be /Users/AnneLutz/Documents in order for what you type to work.
That said you should add /Users/AnneLutz/Documents/google-cloud-sdk/bin to you path. To do this, assuming you are using bash you can
source /Users/AnneLutz/Documents/google-cloud-sdk/path.bash.inc
To make it so that every-time you start your shell you can add it to shell profile. For example you can add above source command at the end of ~/.bash_profile file.
It looks like you used the option to download the SDK zip file and are then trying to configure your environment with that download option. If you aren't comfortable with setting environment variables, you might want to instead try installing using the "interactive" installer, which will automate the steps for making the commands always available on your system.
The directions are here, but for Mac OS users are basically:
Enter the following at a command prompt:
curl https://sdk.cloud.google.com | bash
Restart your shell:
exec -l $SHELL
Run gcloud init to initialize the gcloud environment:
gcloud init
For many, this procedure is easier than getting everything configured manually.
When I try to update my appengine project, it gives me an error.
$ sudo gcloud app deploy
ERROR: (gcloud.app.deploy) Staging command [/usr/local/google-cloud-sdk/platform/google_appengine/goroot-1.6/bin/go-app-stager /Users/baz/app/app.yaml /tmp/tmpSZLK/tmpIQ4] failed with return code [1].
------------------------------------ STDOUT ------------------------------------
------------------------------------ STDERR ------------------------------------
2017/07/08 16:22:06 failed analyzing /Users/baz/app: cannot find package "bitbucket.org/foo/bar" in any of:
($GOROOT not set)
($GOPATH not set)
GOPATH:
$ echo $GOPATH
/Users/baz/go
$ go env GOPATH
/Users/baz/go
Clearly GOPATH is set (I export it in my .bash_profile).
TL;DR - Do not use sudo for deploying the app.
Longer version
You're running the gcloud app deploy command using sudo. sudo by the nature of the command will not retain the current set of environment variables when running the command as root user.
Try deploying your app engine app without sudo:
gcloud app deploy
If you do need to run you command as sudo (which is a smell that your setup is broken somehow), you can look at this post. Although, I would recommend looking into the possibility of running your command without sudo.
How do I change the home directory to which gcloud copies files. I'm using the following command to copy a file from a local Windows account to Ubuntu which is hosted in a Google Compute Engine instance.
gcloud compute copy-files readme.md compute-engine-instance:readme.md
For some crazy reason the readme file will end up in a remote home directory with the same name as my local user account. I would like to specify which home directory on the compute engine to copy that file to.
gcloud compute copy-files and other SSH-related commands default to using the name of the local user as the username on the remote host (note that this is very similar to the behavior of plain ssh).
Try gcloud compute copy-files readme.md otheruser#compute-engine-instance: instead.
As you can see in gcloud compute copy-files --help, the command has the following specification:
gcloud compute copy-files [[USER#]INSTANCE:]SRC [[[USER#]INSTANCE:]SRC ...]
[[USER#]INSTANCE:]DEST [--dry-run] [--plain]
[--ssh-key-file SSH_KEY_FILE] [--zone ZONE] [GLOBAL-FLAG ...]
You can specify either a user, or a full path to do what you want.
gcloud compute copy-files readme.md user#compute-engine-instance:readme.md
or
gcloud compute copy-files readme.md compute-engine-instance:/home/user/readme.md
The destination can also be a directory. So these would work as well.
gcloud compute copy-files readme.md user#compute-engine-instance:~
or
gcloud compute copy-files readme.md compute-engine-instance:/home/user
I depolyed an app with gcloud preview app deploy.
Is there a way to download it to an other local machine?
How can I get the files? I tried it via ssh with no success (can't access the docker dir)
UPDATE:
I found this:
gcloud preview app modules download default --version 1 --output-dir=my_dir
but it's not loading files
Log
Downloading module [default] to [my_dir/default]
Fetching file list from server...
|- Downloading [0] files... -|
I am coming to Google App Engine after two years, I see that they have made lots of improvements and added tons of features. But sadly, their documentation sometimes leaves much to be desired.
I used to download my code of the uploaded version with the appcfg.pyusing the following command.
appcfg.py download_app -A <app_id> -V <version> <output-dir>
But of course now that they have culminated everything in the gcloud shell where appcfg.py is not accessible.
However, the following method helped me to download the deployed code:
Go the console and in to the Google App Engine.
Select the project you want to work with.
Once the project's dashboard opens, Click on the top right to
open the built in console window.
Which should load the cloud shell at the bottom, now if you check appcfg.py is available to you to use in this VM.
Hence, use appcfg.py download_app -A <app_id> -V <version> <output-dir> to download the code.
Now once you have the code in the desired folder, in order to download it on your local machine - You can open the docker code editor
Now here I assumed if I rightclicked and exported the desired
folder it would work,
but instead it gave me the following error message.
{"Error":"'concurrency' must be a number but it is [object Undefined]","Message":"'concurrency' must be a number but it is [object Undefined]"}
So, I thought maybe it would play along nicely if the the folder
was an archive. Go back to the cloud shell and using whatever
utility you fancy make an archive of the folder
zip -r mycode.zip mycode
Go to the docker code editor, export and download.
Now. Of course there might many more ways do it (hopefully) but this is what made sense to me after returning to Google App Engine after 2 years.
Currently, the best way to do this is to pull the files out of Docker.
Put instance into self-managed mode, so that you can ssh into it:
$ gcloud preview app modules set-managed-by default --version 1 --self
Find the name of the instance:
$ gcloud compute instances list | grep gae-default-1
Copy it out of the Docker container, change the permissions, and copy it back to your local machine:
$ gcloud compute ssh --zone=us-central1-f gae-default-1-1234 'sudo docker cp gaeapp:/app /tmp'
$ gcloud compute ssh --zone=us-central1-f gae-default-1-1234 "chown -R $USER /tmp/app"
$ gcloud compute copy-files --zone=us-central1-f gae-default-1-1234:/tmp/app /tmp/
$ ls /tmp/app
Dockerfile
[...]
IMHO, the best option today (Aug 2018) is:
Under the main menu, under Products, go to Tools -> Cloud Build -> Build history.
There, click the ID of the build you want.
Then, in the opened window (Build details), click the source link, the download of your compressed code begins.
As simple as that.
HTH.
As of Feb 2021, you can install appengine-sdk using pip
pip install appengine-sdk
Once installed, appcfg can be used to download the app code.
python -m appcfg download_app -A app_id [ -V version ] out-dir
Nothing works. Finally I found the source code this way. Simply go to google cloud storage. choose buckets starting with us.artifacts...., select containers > images > download the latest one (look by created date). unzip after downloaded file. it will have all the deployed source code of app engine.
I've followed the Docker instructions from here exactly: https://cloud.google.com/sdk/#install-docker (click Alternative Methods to find Docker instructions).
But when I run:
docker run -t -i --volumes-from gcloud-config google/cloud-sdk gcloud compute instances list
I get:
docker run -t -i --volumes-from gcloud-config google/cloud-sdk gcloud compute instances list
ERROR: (gcloud.compute.instances.list) You do not currently have an active account selected.
Please run:
$ gcloud auth login
to obtain new credentials, or if you have already logged in with a
different account:
$ gcloud config set account <account name>
to select an already authenticated account to use.
It doesn't look like it's picking up that I already authenticated. Any ideas?
The link doesn't point to anything about Docker, could you give correct link.
The encountered error output is pointing you to follow the two-step Google verification. If you provide :
gcloud auth login
command, the verification process will start, and then you will be able to manipulate your Google CLoud project
However this page [1] could guide you installing Docker on Google Cloud.
[1] - http://docs.docker.com/installation/google/