Run your React app on Google Cloud

  Рет қаралды 19,706

Google Cloud Tech

Google Cloud Tech

Күн бұрын

Пікірлер: 71
@googlecloudtech
@googlecloudtech 11 ай бұрын
Subscribe so you never miss an episode of Serverless Expeditions! → goo.gle/GoogleCloudTech
@gregoryg3109
@gregoryg3109 4 ай бұрын
Thank you, Martin, I thought it was an excellent introduction to how to deploy a React app to Google Cloud for someone who had never done it, it really helped to get me started. However, I want to bring everyone's attention to 13:57 where it is said the Load Balancer integration incurs a min monthly cost of $20. I personally needed only to connect a domain to my WIP app so I immediately followed the steps first, and if I didn't listen carefully later I would end up paying that extra $20 to Google without even knowing it. In my opinion, such important information should be presented upfront, as clearly as possible, rather than just being mentioned passingly. Otherwise, great video!
@TheMomander
@TheMomander 4 ай бұрын
You can also use Firebase Hosting to point your custom domain to your Cloud Run service. It does not incur a fixed monthly cost. Search for "firebase hosting cloud run" and you will find the right docs.
@LeonBlade
@LeonBlade 2 ай бұрын
Such a great intro to cloud run. I worked with GCP on my last project, but I wasn't part of devops so I only know a little bit about it. We would deploy from Github to Cloud Run and had different environments. This helps me understand a bit more about the process. Thank you, your videos are really good.
@TheMomander
@TheMomander 2 ай бұрын
Happy to hear the video was useful to you!
@eduardocoronado5145
@eduardocoronado5145 11 ай бұрын
Thanks, Martin really appreciate the practical example! The info about pricing and the extra 3 optional steps were really helpful. I'd like to see a similar tutorial with pub/sub in future videos.
@TheMomander
@TheMomander 11 ай бұрын
Thank you for the suggestion! Happy to hear you found the video useful.
@SmitaDebata
@SmitaDebata 2 ай бұрын
Absolutely amazing video for anyone to get started with how to build and deploy an app on google cloud
@TheMomander
@TheMomander 2 ай бұрын
Happy to hear you found it useful! You may also want to check out our video "Run your Next.js app on Cloud Run".
@dheer211
@dheer211 11 ай бұрын
Thanks Martin. What about the pros and cons of deploying separate Cloud Run services (For React and Server side Express) versus your approach of packaging both frontend and backend in a single image? With a single service it is a very simple architecture and perhaps lower costs but regardless of changes with only Frontend aka FE (React) only Backend aka BE (Express) entire app still needs to deployed. The advantage of using separate Cloud Run services is that it provides individual scaling of FE and BE plus the flexibility of deploying only FE or only BE with increased security by having the option to make the BE service internal ONLY but yes complex architecture in setting up service to service communication.
@TheMomander
@TheMomander 11 ай бұрын
Good points! I think you summarized the pros and cons very well. Three more thoughts: 1. CI/CD and rollbacks become easy if your application is a single container. In many web apps, the front-end and back-end are tightly coupled with each other, so deploying one without the other may not be a strong need, and it may make automated testing difficult. 2. On the other hand, I have heard from some teams that want to let web designers deploy new graphics without being part of the CI/CD pipeline. In that case it may be useful to store the graphics outside the container, like in a Storage bucket. That bucket can be used by multiple web apps, making it easy to update a logo for all apps at once. 3. Independent scaling of backend vs frontend is useful if you are managing virtual machines, less so in serverless where scaling is automatic.
@rakeshb2010
@rakeshb2010 10 ай бұрын
​@@TheMomanderThanks for the video. Can you please make a video on React/Postgres security on GCP like DDoS, Firewall, https, encryption etc.
@TheMomander
@TheMomander 10 ай бұрын
@@rakeshb2010 Thank you for the suggestion!
@dheer211
@dheer211 10 ай бұрын
@@TheMomander Thanks so much Martin appreciate your reply. One other question I have is whether it is possible to use the googel-auth client library on client side more specifically in a React JS CR service deployed as a public front end service or is it supposed to work server side?
@TheMomander
@TheMomander 10 ай бұрын
@@dheer211 Firebase Authentication is meant to be deployed on the client and works well with React. If you prefer more enterprise features (and don't mind paying a little more) you should check out Google Cloud Identity Platform. Both products use the same client-side libraries, so it's easy to switch between them.
@harshkumar7686
@harshkumar7686 9 ай бұрын
I was literally dying to see someone let me go through this process. Thanks a lot
@TheMomander
@TheMomander 8 ай бұрын
Happy to hear it was useful!
@babyai24
@babyai24 7 ай бұрын
This is great! Could you please make text-music or text-text or text-image ai apps with react native and then publish on gcp? Thank you, sir.
@TheMomander
@TheMomander 7 ай бұрын
We just released such a video. Do a KZbin search for "Serverless Generative AI" and you will find it!
@MrGudmestad
@MrGudmestad 11 ай бұрын
I'm able to get the front and backend working together on localhost, but the landing page of the React app isn't hit when deployed to Google Cloud with "error": "Sorry couldn't find /". The error is looking for my home route which was never set. Should I create a home route and send the index file? I wouldn't think so since it's working nicely together on localhost. Maybe a Google Cloud setting?
@MrGudmestad
@MrGudmestad 11 ай бұрын
When I navigate to /index.html, it returns "error": "Sorry couldn't find /index.html" - It just seems that Google Cloud doesn't see my React App
@MrGudmestad
@MrGudmestad 11 ай бұрын
If I create a home route and res.send('hello world") and the browser will receive that instead of my React App 😑
@TheMomander
@TheMomander 11 ай бұрын
@@MrGudmestad Here are the two things I would check in this situation: 1. Did you include the express.static("react-app/dist") call at 3:53 of the video? 2. Seen from the Node.js app's directory, does "react-app/dist" point to a directory that includes an index.html file?
@MrGudmestad
@MrGudmestad 11 ай бұрын
@@TheMomander Thank you for the reply! Yes, I absolutely completed item #1 on your checklist and without that line of code, the React App doesn't work on localhost. I am confused a little by #2 though. Yes, there is an index.html file inside of my dist folder. Again, the weirdest part in my view is that the React App does work on Localhost but not on Google Cloud.
@MartinOmander
@MartinOmander 11 ай бұрын
@@MrGudmestad Have you had a chance to check the server-side log in the Google Cloud Console? There may be clues in that log.
@JCDovemail
@JCDovemail 5 ай бұрын
Nice!
@kumarnatarajan3132
@kumarnatarajan3132 9 ай бұрын
great tutorial . thanks
@STEMMadeSimple2023
@STEMMadeSimple2023 2 ай бұрын
Is it possible to deploy this application on Google Cloud Run with the Continuous Deployment button and GitHub?
@TheMomander
@TheMomander 2 ай бұрын
Yes, it is. I shot another video titled "Run your Next.js app on Cloud Run" which shows how to set up continuous deployment for React apps on Cloud Run. Do a KZbin search for it and have a look. Best of luck with your project!
@STEMMadeSimple2023
@STEMMadeSimple2023 2 ай бұрын
@@TheMomander Thank you so much for making a video about this topic! I am looking forward to watching the video and following the steps.
@JarrettKirk
@JarrettKirk Ай бұрын
Is there a difference between deploying to Google's Cloud Run service and Google's App Engine service? When should you use one or the other?
@TheMomander
@TheMomander 29 күн бұрын
Either App Engine or Cloud Run would work. If you are familiar with one of the two, use that one! If you are equally familiar with both, or you haven't tried either yet, I would go with Cloud Run. Cloud Run is more modern, it is container-based, and it gives you more freedom, for example to include binary libraries.
@MostafaMohamedRawash
@MostafaMohamedRawash 6 ай бұрын
thank you Mr.Martin Omander for this helpful video
@lssam100
@lssam100 2 ай бұрын
why did you switch the locaiton of index.js from being i the pirate-app directory to react-app/src at 3:50?
@TheMomander
@TheMomander 2 ай бұрын
Looks like I made a mistake when editing this video. The index.js file should be in the pirate-app directory and it should not be moved. Sorry about that.
@rahullabroo0
@rahullabroo0 2 ай бұрын
Please give tut on database integration with gcp both sql & no sql
@TheMomander
@TheMomander 2 ай бұрын
Thank you for the suggestion. If you search for "Hosting a REST API with a Cloud Firestore backend" and "Cloud Run + Cloud SQL, setup" here on KZbin you will find two videos that address those scenarios. Hope you'll find them helpful!
@yansongguo8354
@yansongguo8354 6 ай бұрын
Hi! Martin, really like the videos. How about create a terraform version with github action for this template integration:)
@TheMomander
@TheMomander 5 ай бұрын
Thank you for the suggestion!
@tanmayupadhyay7750
@tanmayupadhyay7750 11 ай бұрын
@googlecloudtech - I had a question ... I built a react website with no backend(no server code) and simply hosted it on cloud run with a domain I had purchased. Is there any downside in this type of deployment? What I am wondering is security? How should I do a user authentication within FE? If I have to create another service on cloud run for authentication, How would i secure the communication between the 2 services (react app FE and user authentication service).
@TheMomander
@TheMomander 11 ай бұрын
Your deployment sounds good. For authentication, I propose you implement Firebase Authentication. Once that is done, whenever your front-end code is sending a request to your backend code, attach a token from Firebase Authentication to that request. In your backend code you'd validate the token, which would give you the ID of the user. Do a web search for "firebase authentication verify id tokens" and you will find sample code. Best of luck with your project!
@codevalley9511
@codevalley9511 11 ай бұрын
Great, thanks
@Universal7135
@Universal7135 10 ай бұрын
Hi Martin! Thank you so much for the great video. I run into an error at around the 11:00 minute mark. I get the error that the user-provided container failed to start and listen to the correct port. What can I do to ensure the container starts? Does GCP build a container for me when I follow the instructions in this video?
@TheMomander
@TheMomander 10 ай бұрын
Yes, Google builds the container for you. You can go to the Cloud Console and check the logs (hamburger menu in the upper left, then Logging, then Log Explorer). Most of the time when I get the error you described it's one of these two causes: 1. I forgot to include *"start": "node index.js"* in the scripts section of package.json of the Express app. Google is looking for that script and will run it to start your container. See 5:54 in the video. 2. I used *import* in my code (instead of require) and I forgot to add *"type": "module"* in package.json of the Express app. Hope this helps!
@boonlertchin
@boonlertchin 3 ай бұрын
I love this solution.
@TheMomander
@TheMomander 3 ай бұрын
Happy to hear you found it useful!
8 ай бұрын
11:48 after deploying and folowing the link I get a 404 instead of the react app, but the API works fine. It looks like google cloud did not use the dist folder. Any ides?
@jjfattz
@jjfattz 6 ай бұрын
This is most likely because you don't have a .gcloudignore file in your root project folder. When that file doesn't exist, gcloud will default to your .gitignore file. Your .gitignore file most likely has the "dist" folder in it to exclude. So that is why the folder does not exist. You can basically just copy paste your .gitignore file into a .gcloudignore file, but remove the "dist" folder from it.
@Eus4ebius
@Eus4ebius 6 ай бұрын
@@jjfattzthanks a bunch!
@JavierGopar
@JavierGopar 10 ай бұрын
And to do it with React and NextJS ?
@MartinOmander
@MartinOmander 10 ай бұрын
That's a great idea. I will add it to my list of upcoming episodes. Thanks for the suggestion!
@drose91
@drose91 5 ай бұрын
google cloud says [Error: ENOENT: no such file or directory, open './dist/client/index.html'] {
@hendoitechnologies
@hendoitechnologies 4 ай бұрын
We face difficulty to host out react js website built on vs code...
@Christina-fg4jp
@Christina-fg4jp 3 ай бұрын
How do you deploy a react application with a python server all with google cloud run?
@Christina-fg4jp
@Christina-fg4jp 3 ай бұрын
actually I figured it out
@MartinOmander
@MartinOmander 3 ай бұрын
@@Christina-fg4jp That's good to hear -- well done!
@msj5297
@msj5297 11 ай бұрын
1 cmd
@deindedawodu1563
@deindedawodu1563 10 ай бұрын
Awesome!
@davidspiess2047
@davidspiess2047 11 ай бұрын
Great video! The new load balancer integration is nice, but even if Cloud Run creates all the necessary resource types for you, it doesn't solve the problem that understanding and configuring a load balancer is still a very complex task.
@TheMomander
@TheMomander 11 ай бұрын
I agree that configuring a load balancer from scratch is complicated, and I personally avoid it. But if you click the "Integrations" tab like I did in the video at 13:13, all you have to do is fill out a single form. Google Cloud does complicated parts for you.
@frugalcode
@frugalcode 11 ай бұрын
Astro + Vercel.
@serbrad6426
@serbrad6426 Ай бұрын
BS
@mrequency
@mrequency 9 ай бұрын
Hi, I am having problem deploying the App. Deployment failed ERROR: (gcloud.run.deploy) FAILED_PRECONDITION: failed precondition: due to quota restrictions, cannot run builds in this region. Please contact support. When I check it seems I have quota, I am not sure why this happening
@TheMomander
@TheMomander 8 ай бұрын
Not sure what is happening. I propose you post your question in the Google Cloud sub-reddit.
Cloud Run to VPC, simplified
10:14
Google Cloud Tech
Рет қаралды 8 М.
Cloud Functions vs. Cloud Run
20:37
Google Cloud Tech
Рет қаралды 48 М.
Офицер, я всё объясню
01:00
История одного вокалиста
Рет қаралды 3,7 МЛН
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,7 МЛН
WORLD BEST MAGIC SECRETS
00:50
MasomkaMagic
Рет қаралды 54 МЛН
Google App Engine - how to deploy React client and Node.js API Server
1:03:31
Picking the right serverless platform (Part 1)
14:02
Google Cloud Tech
Рет қаралды 15 М.
How to deploy a dockerized FastAPI to Cloud Run
22:22
COMMAND
Рет қаралды 2,7 М.
How I deploy serverless containers for free
6:33
Beyond Fireship
Рет қаралды 507 М.
How To Deploy A React App - Using NGINX & Linux
23:09
Tech With Tim
Рет қаралды 85 М.
Deploy your Flask app on Google Cloud Platform
17:51
Leslie Wubbel
Рет қаралды 17 М.
Cloud Run user auth for internal apps
15:31
Google Cloud Tech
Рет қаралды 18 М.
13 Things To Remove From Your Website Immediately
12:33
Orbit Media Studios
Рет қаралды 318 М.
Master React JS in easy way
12:18
Nova Designs
Рет қаралды 94 М.