如何在不同于app.yaml的文件夹中上载Google App Engine(Go)项目 [英] How to upload a Google App Engine (Go) project in a different folder than the app.yaml
问题描述
我的项目具有以下结构:
My project has the following structure:
| appengine
|---- app.yaml
|---- myScript.go
| bower_components
|----|...
| build
|----|images
|----|----|branding
|----|----|---- favicon.ico
|----|styles
|----|----|*.css
|----|index.html
| src
| ...
我想在运行<$ c $时上载build文件夹的全部内容c> goapp部署appengine 。
我的app.yaml看起来像这样:
My app.yaml looks like this:
application: myProject
version: 0-1
runtime: go
api_version: go1
handlers:
- url: /(.*\.(gif|png|jpg|ico|js|css))
static_files: ../build/\1
upload: ../build/(.*\.(gif|png|jpg|ico|js|css))
- url: /.*
script: _go_app
和myScript.go看起来像这样:
and myScript.go looks like this:
package myProject
import (
"fmt"
"io/ioutil"
"net/http"
)
func init() {
http.HandleFunc("/", handler)
}
func handler(w http.ResponseWriter, r *http.Request) {
site, err := ioutil.ReadFile("../build/index.html")
if err != nil {
panic(err)
}
fmt.Fprint(w, string(site))
}
当我运行 goapp serve appengine
,网站将正确显示。但是,当我尝试部署它时,它只会克隆两个文件,即appengine文件夹中的文件。
When I run goapp serve appengine
, the website displays properly. However, when I try to deploy it, it only clones two files, i.e. the ones inside the appengine folder.
推荐答案
通过保留在GAE应用程序代码目录之外的第三方代码来保留所需的应用程序结构,而只需将GAE应用程序目录中的第三方代码文件/目录符号链接到所需的目录中,仍然能够将第三方代码与GAE应用程序代码一起上传
You can preserve your desired app structure with 3rd party code residing outside your GAE app code directory yet still be able to upload the 3rd party code together with your GAE app code by just symlinking the 3rd party code files/dirs inside the GAE app dir in the desired locations.
GAE上载/部署实用程序知道要替换符号链接并在相应位置上载符号链接指向的实际文件/目录。
The GAE upload/deploy utilities know to replace the symlinks and upload the actual files/dirs the symlinks point to instead, in the respective locations.
可以在其中应用符号链接技术的其他一些与GAE相关的场景:
Some other GAE-related scenarios in which the symlink technique can be applied:
- 在App Engine模块之间共享实体
- 如何在App Engine模块之间共享文件(HTML模板)?
- 我是否需要跨多个YAML文件复制`skip_files` ?
- 如何从Python Google App Engine中的模块访问供应商库?
- < href = https://stackoverflow.com/questions/34110178/can-a-default-module-in-a-google-app-engine-app-be-a-sibling-of-a-non-default- mo / 34111170#34111170>就文件夹结构而言,Google App Engine应用程序中的默认服务/模块是否可以成为非默认服务/模块的兄弟?
- Sharing entities between App Engine modules
- How can I share files (HTML templates) between App Engine modules?
- Do I need to copy `skip_files` across multiple YAML files?
- How do I access a vendored library from a module in Python Google App Engine?
- Can a default service/module in a Google App Engine app be a sibling of a non-default one in terms of folder structure?
这篇关于如何在不同于app.yaml的文件夹中上载Google App Engine(Go)项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!