Missing a step to update a static ReactJS site on GCloud

断了今生、忘了曾经 提交于 2019-12-10 14:12:54

问题


One would think that simply replacing the contents in the bucket associated with the app would update the app, but that is not the case.


I have a site that I deployed yesterday. I created the bucket, then in the command line created the directory, then deployed the React app doing
gsutil rsync -r gs://bucket-name ./app-name

then I went into the project directory and did

gcloud app deploy

it all worked fine yesterday. But today i made changes, going into the same directory, you simply can't just do gcloud app deploy again. I copied the new build folder into the bucket. But there seems to be a missing step? I ran the same command as yesterday thinking maybe the rsync would sync the bucket to the app, then I went back into the app and did another deploy. yet nothing has changed. What step am i missing?


This question is not related to: How to Quickly Update Static Site on Google Cloud Storage?

回答1:


Below is a simple solution that actually works. Google's documentation is far overcomplicated and of little use. And their "tech support" was not able to resolve the issue.


This is how I was able to update my static site on gcloud using the command line utility.

  • Create a new bucket, ideally name it with a version like appname-v2
  • Copy your recent build into that bucket
  • Delete the old bucket
  • From your main area in your console where you see your app's directory do gsutil rsync -r gs://[bucketname] ./appname
  • cd into the directory
  • run gcloud app deploy

So if your latest version of your app is 3, if your app's directory is stackoverflow, and your bucket is "bucket" then your gsutil command would look like

gsutil rsync -r gs://bucket-v3 ./stackoverflow

Gcloud console - shows naming for bucket's version

Deployed site - test


There are plenty of related questions, they drone on and on and on about "cache" etc. It's all pointless to read. Just delete the old bucket and redeploy.

Of course this was for a small app, there are ways to "properly do it" but good luck finding it in the documentation. Everyone that I know that works with gcloud has several workarounds.



来源:https://stackoverflow.com/questions/50032160/missing-a-step-to-update-a-static-reactjs-site-on-gcloud

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!