0
votes

Here is my package.json

"scripts": {
    "start": "react-scripts start",
    "start:develop": "env-cmd -f env/.env.develop react-scripts start",
    "start:stage": "env-cmd -f env/.env.stage react-scripts start",
    ...
}

env folder structure

env
├─ .env.develop (env=develop)
├─ .env.stage   (env=stage)

When run on local (MacOS)

  • "yarn start" runs NodeJS app on local with default "env" = local (which is defined in other file)
  • "yarn start:develop" runs NodeJS app on local with "env" = develop

But now when I want to deploy this to GCP AppEngine, it's always deploy with "start" command (equivalent to "yarn start" on local)

How can I deploy "yarn start:develop" to AppEngine without declaring more environment variables in app.yaml?

1

1 Answers

0
votes

From the documentation about what happens when you deploy your program,

Node.js modules are installed in the cloud as listed in your package.json and package-lock.json files and your service is started by using npm start.

I interpret the above to mean your project on the cloud is always run with start script and GAE will not/does not know how to use another script.

A possible workaround could be to deploy your app using a different version name e.g. dev i.e. you have

  1. Your default version with "start": "react-scripts start"
  2. dev version with "start": "env-cmd -f env/.env.develop react-scripts start"

Both of your versions use only the start script but they do different things