简体   繁体   English

gcloud:如何通过cli下载应用程序

[英]gcloud: how to download the app via cli

I depolyed an app with gcloud preview app deploy.我使用 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)我通过 ssh 尝试过但没有成功(无法访问 docker 目录)

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.两年后我来到 Google App Engine,我看到他们进行了很多改进并添加了大量功能。 But sadly, their documentation sometimes leaves much to be desired.但遗憾的是,他们的文档有时还有很多不足之处。

I used to download my code of the uploaded version with the appcfg.py using the following command.我曾经使用以下命令使用appcfg.py下载上传版本的代码。

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.但是当然现在他们已经在 gcloud shell 中完成了appcfg.py不可访问的所有内容。

However, the following method helped me to download the deployed code:但是,以下方法帮助我下载了部署的代码:

  1. Go the console and in to the Google App Engine.转到控制台并进入 Google App Engine。
  2. Select the project you want to work with.选择您要使用的项目。

  3. Once the project's dashboard opens, Click on the top right to open the built in console window.项目的仪表板打开后,单击右上角以打开内置控制台窗口。

    在此处输入图片说明

  4. Which should load the cloud shell at the bottom, now if you check appcfg.py is available to you to use in this VM.现在,如果您检查appcfg.py是否可供您在此 VM 中使用,则应在底部加载云外壳。

    输入图片描述她[2]

  5. Hence, use appcfg.py download_app -A <app_id> -V <version> <output-dir> to download the code.因此,使用appcfg.py download_app -A <app_id> -V <version> <output-dir>下载代码。

  6. 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现在,一旦您在所需文件夹中拥有代码,就可以将其下载到本地计算机上 - 您可以打开 docker 代码编辑器

    在此处输入图片说明

  7. 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]"}
  8. 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
  9. Go to the docker code editor, export and download.转到 docker 代码编辑器,导出并下载。

    在此处输入图片说明

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.当然,可能有更多的方法来做到这一点(希望如此),但在 2 年后返回 Google App Engine 后,这对我来说是有意义的。

Currently, the best way to do this is to pull the files out of Docker.目前,最好的方法是从 Docker 中提取文件。

Put instance into self-managed mode, so that you can ssh into it:将实例置于自我管理模式,以便您可以 ssh 进入它:

$ 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:将其从 Docker 容器中复制出来,更改权限,然后将其复制回本地机器:

$ 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:恕我直言,今天(2018 年 8 月)的最佳选择是:

Under the main menu, under Products, go to Tools -> Cloud Build -> Build history .在主菜单下的 Products 下,转到Tools -> Cloud Build -> Build history

There, click the ID of the build you want.在那里,单击所需构建的 ID。

Then, in the opened window (Build details), click the source link, the download of your compressed code begins.然后,在打开的窗口(构建详细信息)中,单击source链接,开始下载您的压缩代码。

As simple as that.就如此容易。

HTH.哈。

As of Feb 2021, you can install appengine-sdk using pip自 2021 年 2 月起,您可以使用 pip 安装 appengine-sdk

pip install appengine-sdk

Once installed, appcfg can be used to download the app code.安装后,可以使用 appcfg 下载应用程序代码。

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.只需 go 到谷歌云存储。 choose buckets starting with us.artifacts...., select containers > images > download the latest one (look by created date).选择以 us.artifacts.... 开头的桶,select 容器 > 图像 > 下载最新的(按创建日期查看)。 unzip after downloaded file.下载文件后解压。 it will have all the deployed source code of app engine.它将拥有应用引擎的所有已部署源代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM