【问题标题】:Appengine app deployment is not uploading some foldersAppengine 应用程序部署未上传某些文件夹
【发布时间】:2018-11-24 06:35:54
【问题描述】:

我在 AppEngine 上部署了一个应用。 当我在本地测试应用程序时,一切正常。 我已经完成了 composer install 并且“vendor”文件夹存在。

当我查看源代码时,我可以看到一些文件夹没有上传。 这是我在本地驱动器上的文件夹结构:

我使用此代码进行部署:

gcloud app deploy --promote --stop-previous-version app.yaml

部署的结构如下所示:

如您所见,只上传了 dialpad_research 文件夹。 我的 app.yaml 文件是这样的:

runtime: php55
api_version: 1
threadsafe: true

env_variables:

handlers:
- url: /(.*\.(appcache|manifest))
  mime_type: text/cache-manifest
  static_files: static/\1
  upload: static/(.*\.(appcache|manifest))

- url: /dialpad_research/(.*\.(appcache|manifest))
  mime_type: text/cache-manifest
  static_files: dialpad_research/static/\1
  upload: dialpad_research/static/(.*\.(appcache|manifest))

- url: /(.*\.atom)
  mime_type: application/atom+xml
  static_files: static/\1
  upload: static/(.*\.atom)

- url: /(.*\.crx)
  mime_type: application/x-chrome-extension
  static_files: static/\1
  upload: static/(.*\.crx)

- url: /(.*\.css)
  mime_type: text/css
  static_files: static/\1
  upload: static/(.*\.css)

- url: /(.*\.eot)
  mime_type: application/vnd.ms-fontobject
  static_files: static/\1
  upload: static/(.*\.eot)

- url: /(.*\.htc)
  mime_type: text/x-component
  static_files: static/\1
  upload: static/(.*\.htc)

- url: /(.*\.html)
  mime_type: text/html
  static_files: static/\1
  upload: static/(.*\.html)

- url: /(.*\.ico)
  mime_type: image/x-icon
  static_files: static/\1
  upload: static/(.*\.ico)

- url: /(.*\.js)
  mime_type: text/javascript
  static_files: static/\1
  upload: static/(.*\.js)

- url: /(.*\.json)
  mime_type: application/json
  static_files: static/\1
  upload: static/(.*\.json)

- url: /(.*\.otf)
  mime_type: font/opentype
  static_files: static/\1
  upload: static/(.*\.otf)

- url: /(.*\.rss)
  mime_type: application/rss+xml
  static_files: static/\1
  upload: static/(.*\.rss)

- url: /(.*\.safariextz)
  mime_type: application/octet-stream
  static_files: static/\1
  upload: static/(.*\.safariextz)

- url: /(.*\.(svg|svgz))
  mime_type: images/svg+xml
  static_files: static/\1
  upload: static/(.*\.(svg|svgz))

- url: /(.*\.swf)
  mime_type: application/x-shockwave-flash
  static_files: static/\1
  upload: static/(.*\.swf)

- url: /(.*\.ttf)
  mime_type: font/truetype
  static_files: static/\1
  upload: static/(.*\.ttf)

- url: /(.*\.txt)
  mime_type: text/plain
  static_files: static/\1
  upload: static/(.*\.txt)

- url: /(.*\.unity3d)
  mime_type: application/vnd.unity
  static_files: static/\1
  upload: static/(.*\.unity3d)

- url: /(.*\.webm)
  mime_type: video/webm
  static_files: static/\1
  upload: static/(.*\.webm)

- url: /(.*\.webp)
  mime_type: image/webp
  static_files: static/\1
  upload: static/(.*\.webp)

- url: /(.*\.woff)
  mime_type: application/x-font-woff
  static_files: static/\1
  upload: static/(.*\.woff)

- url: /(.*\.xml)
  mime_type: application/xml
  static_files: static/\1
  upload: static/(.*\.xml)

- url: /(.*\.xpi)
  mime_type: application/x-xpinstall
  static_files: static/\1
  upload: static/(.*\.xpi)

# audio files
- url: /(.*\.(mid|midi|mp3|wav))
  static_files: static/\1
  upload: static/(.*\.(mid|midi|mp3|wav))

# windows files
- url: /(.*\.(doc|exe|ppt|rtf|xls))
  static_files: static/\1
  upload: static/(.*\.(doc|exe|ppt|rtf|xls))

# compressed files
- url: /(.*\.(bz2|gz|rar|tar|tgz|zip))
  static_files: static/\1
  upload: static/(.*\.(bz2|gz|rar|tar|tgz|zip))

# index files
- url: /(.*)/
  static_files: static/\1/index.html
  upload: static/(.*)/index.html

- url: /dialpad_research/api/(.+\.php)$
  script: dialpad_research/api/\1

- url: /vendor/(.+\.php)$
  script: vendor/\1

# site root
- url: /
  static_files: static/index.html
  upload: static/index.html


- url: /static
  static_dir: static


- url: /dialpad_research/static
  static_dir: dialpad_research/static

# dialpad root
- url: /dialpad_research.*
  static_files: dialpad_research/static/index.html
  upload: dialpad_research/static/index.html

# portfolio redirect
- url: /portfolio/.*
  static_files: static/red.html
  upload: static/red.html

# G2 redirect
- url: /g2.*
  static_files: static/red.html
  upload: static/red.html

# Blog redirect
- url: /blog.*
  static_files: static/red.html
  upload: static/red.html

# SSDESIGN redirect
- url: /ssdesign.*
  static_files: static/red.html
  upload: static/red.html

# Colours redirect
- url: /colours.*
  static_files: static/red.html
  upload: static/red.html

知道我在这里可能做错了什么吗?

谢谢

【问题讨论】:

    标签: google-app-engine google-cloud-platform


    【解决方案1】:

    static 目录在 GAE 上预计会丢失,因为它是通过 static_dir 处理程序处理的,因此默认情况下它不会与应用代码一起上传。如果您希望它与应用代码一起上传,您需要为其设置application_readable。来自Handlers element

    应用程序可读

    可选。布尔值。默认情况下,在静态文件处理程序中声明的文件 作为静态数据上传,仅提供给最终用户。他们 应用程序无法读取。如果该字段设置为 true,则 文件也作为代码数据上传,因此您的应用程序可以读取 他们。两次上传都针对您的代码和静态数据收费 存储resource quotas.

    这同样适用于通过 static_file 处理程序提供的所有单个文件。

    vendor 目录的情况有所不同 - 没有静态文件/目录引用它。

    我还看不出vendor 没有从您帖子的信息中上传的原因。您可以尝试的事情:

    • 使用--verbosityglobal option 增加部署命令的详细程度,它应该提及哪些文件/目录被跳过以及为什么。
    • 如果您的服务中有 .gcloudignore file,请检查其内容

    【讨论】:

    • 感谢您的回复丹。我理解静态在这里不可见。供应商文件夹不是我创建的,它是自动创建的。那么,您是否建议我以不同的方式命名它然后更改我的代码?在这种情况下,由 Composer 重命名系统生成的文件夹是否是个好主意?
    • 只是作为一个测试,看看它是否与它丢失有关。它甚至不必工作,您只是想看看它是否已部署。
    • 哦,明白了。让我试试看。
    • 这似乎行得通。我将文件夹名称更改为“发件人”并上传。供应商没有。
    • IT WORKS :) .gcloudignore 正在阻止上传供应商文件夹...即使问题已解决,有人可以解释如何添加忽略文件以及它是如何指定不上传供应商的?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-23
    • 2013-12-23
    • 1970-01-01
    相关资源
    最近更新 更多