Deploy on GCP staging env run the strapi build for production enviroment

Hi, how are you?

I have 3 enviroments (development, staging and production) and when i trying to deploy staging in google cloud app engine with my staging.yaml the console shows the gcp-build command with the message: Building your admin UI with production configuration .

Why is building the admin ui for production enviroment? This is my staging.yaml where NODE_ENV=staging

runtime: nodejs

env: flex

  instances: 1
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

  HOST: ''
  NODE_ENV: 'staging'
  REDISPORT: <port>

#database env configs are in .env file

  cloud_sql_instances: <instance_connection>

# Update with Redis instance network name
  name: default

And here the screenshot when i run “gcloud app deploy staging.yaml”

Thanks for you help!

any update of this?

Hi @alexvais, if possible are you able to share a GitHub link to your project? Maybe you have a .env file that has the NODE_ENV set to production.

Thanks @Richard_Nsama for your answer.

I dosn’t have a NODE_ENV property in my .env file.

I set the NODE_ENV in my app.yaml google cloud env_variables like you see.

If i run yarn gcp-build (that runs strapi build) in my local machine, then it’s building ui for DEVELOPMENT enviroment. But when i deploy to GCP, it’s building for PRODUCTION enviroment as i show you in the images.

I fix the error in a very homemade way but i want to find a good solution… I change the package.json and set:

  "scripts": {
    "develop": "strapi develop",
    "start": "strapi start",
    "build": "strapi build",
    "strapi": "strapi",
    "gcp-build": "NODE_ENV=staging strapi build"

But when i want to deploy to production enviroment i need to change the package.json file.

It’s really weird because when I deploy it runs strapi_build for the production environment, but when the application runs, it sets the staging environment.

I think that passing the NODE_ENV variable in my google cloud app.yaml does not change that before doing the deploy it has to do a build and I don’t know where to specify the enviroment correctly to do that build.

I don’t understand why in my local machine it does it for the DEVELOPMENT enviroment and when I deploy it does it for the PRODUCTION enviroment

Hi @Richard_Nsama

Do you have any update of this issue?

thanks for helping

Hey @alexvais none yet, unfortunately. I’m going to work on a way to reproduce your configuration on my own GCP and see how best I can help with that.