Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing a step to update a static ReactJS site on GCloud

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?
like image 300
JGallardo Avatar asked Oct 16 '22 19:10

JGallardo


1 Answers

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

enter image description here

Deployed site - test

enter image description here


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.

like image 181
JGallardo Avatar answered Oct 26 '22 22:10

JGallardo