在 Google App Engine 上部署时将变量传递给 package.json 中的 gcp-build 方法
Passing variable to gcp-build method in package.json when deploying on Google App Engine
我已成功将 nextjs 站点部署到 google 应用引擎,但是我想通过 env_variable 到 app.yaml 来设置生产和暂存构建。
我在 GAE 文档中看不到如何执行此操作,而且 env_variable 似乎没有发送到 gcp-build
命令。
查看下面我的配置:
# app.yaml
runtime: nodejs
env: flex
service: ss-test
env_variables:
SS_ENV: 'production-test'
# package.json
{
...
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "NODE_ENV=production node server.js",
"gcp-build": "next build", <<<<< I want to pass through the SS_ENV variable from app.yaml here
"deploy:production": "gcloud app deploy"
},
...
}
知道我做错了什么,或者这不可能吗?
提前致谢,为了这个我已经用头撞墙好几个小时了!
亚历克斯
经过研究和实验,Google Cloud Build 是必经之路。
扩展您之前关于云构建使用的回答。对于您问题的上下文,我可以理解您正在尝试使用记录在 here 中的 "Custom Build Step" 选项。这仅在应用程序启动之前在部署期间处理依赖项并使依赖项可用时有用。
使用 Cloud Build 时。您可以使用 gcloud builder, to deploy your GAE with the required configuration. To know a bit more about the gcloud builder you can read this 创建专门的构建步骤。
所需的配置应在 app.yaml 上声明。有关 app.yaml 的更多信息,请参见 here。
我已成功将 nextjs 站点部署到 google 应用引擎,但是我想通过 env_variable 到 app.yaml 来设置生产和暂存构建。
我在 GAE 文档中看不到如何执行此操作,而且 env_variable 似乎没有发送到 gcp-build
命令。
查看下面我的配置:
# app.yaml
runtime: nodejs
env: flex
service: ss-test
env_variables:
SS_ENV: 'production-test'
# package.json
{
...
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "NODE_ENV=production node server.js",
"gcp-build": "next build", <<<<< I want to pass through the SS_ENV variable from app.yaml here
"deploy:production": "gcloud app deploy"
},
...
}
知道我做错了什么,或者这不可能吗?
提前致谢,为了这个我已经用头撞墙好几个小时了! 亚历克斯
经过研究和实验,Google Cloud Build 是必经之路。
扩展您之前关于云构建使用的回答。对于您问题的上下文,我可以理解您正在尝试使用记录在 here 中的 "Custom Build Step" 选项。这仅在应用程序启动之前在部署期间处理依赖项并使依赖项可用时有用。
使用 Cloud Build 时。您可以使用 gcloud builder, to deploy your GAE with the required configuration. To know a bit more about the gcloud builder you can read this 创建专门的构建步骤。
所需的配置应在 app.yaml 上声明。有关 app.yaml 的更多信息,请参见 here。