运行`gcloud app deploy`时如何忽略文件? [英] How to ignore files when running `gcloud app deploy`?

查看:83
本文介绍了运行`gcloud app deploy`时如何忽略文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跑步时

gcloud app deploy app.yaml

实际上上传了哪些文件?

which files actually get uploaded?

项目文件夹包含与已部署的应用程序无关的文件夹和文件,例如.git.git_ignoreMakefilevenv.

The project folder contains folders and files such as .git, .git_ignore, Makefile or venv that are irrelevant for the deployed application.

gcloud app deploy如何决定上传哪些文件?

How does gcloud app deploy decide which files get uploaded?

推荐答案

tl; dr:dr:您应该使用.gcloudignore文件,而不是app.yaml中的skip_files.

tl;dr: you should use a .gcloudignore file, not skip_files in app.yaml.

尽管前两个答案使用了app.yaml文件中的skip_files.现在,使用gcloud deployupload命令时会创建一个.gcloudignore.默认值取决于您使用的检测到的语言,但是这里是在我的Python项目中自动创建的.gcloudignore:

While the prior two answers make use of skip_files in the app.yaml file. There is now a .gcloudignore that is created when using gcloud deploy or upload commands. The default will depend on the detected language that you are using but here is automatically created .gcloudignore that I found in my Python project:

# This file specifies files that are *not* uploaded to Google Cloud Platform 
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
#   $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below: 
.git 
.gitignore

# Python pycache:
__pycache__/

注意:当同时定义了skip_files.gcloudignore时,这些命令将不起作用. skip_files definition of the app.yaml`参考中未提及.

Note: These commands will not work when both skip_files is defined and .gcloudignore is present. This is not mentioned in the skip_filesdefinition of theapp.yaml` reference.

gcloud命令中具有全球公认的标准似乎更好,并且与仅在不使用App Engine时才有用的skip_files相比,采用.gcloudignore更有意义.此外,它的工作原理很像参考文献中提到的.gitignore文件:

It seems better to have a globally recognized standard across gcloud commands and makes more sense to adopt the .gcloudignore versus using the skip_files which is only relevant without App Engine. Additionally, it works pretty much like a .gitignore file which the reference mentions:

.gcloudignore的语法从.gitignore的语法中大量借用; 请参阅 https://git-scm.com/docs/gitignore 或man gitignore以获得完整信息 参考.

The syntax of .gcloudignore borrows heavily from that of .gitignore; see https://git-scm.com/docs/gitignore or man gitignore for a full reference.

https://cloud.google.com/sdk/gcloud/reference/topic/gcloudignore

这篇关于运行`gcloud app deploy`时如何忽略文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆