4

I have a react project code. I want to deploy it on google cloud. I have a build directory in my project which has builds. Here is my project structure. enter image description here

How can I deploy it on google cloud. Can someone please guide me. What all files from my project will I have to put there. I am very new to deploying apps online. Will I need to just put the build folder or will I need to upload complete project there?

EdG
  • 2,243
  • 6
  • 48
  • 103
  • As far as the files required, just the build output is sufficient. However it depends on how the site is hosted as to if you need additional configuration. I have used Firebase hosting (similar to Google cloud) and hosting a react app is quite simple with that. – Andrew Breen Jan 09 '17 at 22:38

1 Answers1

6

React apps are single page applications. Single page applications (SPA) can be hosted as a static website on google cloud storage. Here is the link for hosting a static website on GCP. Similarly, If you want to host reactJS app on AWS S3, here are the steps.

Host the index.html in the root folder of your bucket. Store your bundled react app.js file to sub folders and specify the path in index.html. You can also store other public assets in sub-folder hierarchy.

Community
  • 1
  • 1
Lakshman Diwaakar
  • 7,207
  • 6
  • 47
  • 81
  • So I don't have index.html. I have jade files. Layout.jade, index.jade and error.jade. Where should I put these 3 files. – EdG Jan 10 '17 at 09:18
  • I think it is not possible to change jade to html, as you need some engine to change jade to html in the run time. I have not used jade in SPA. May be, you can use some task runner like gulp or grunt, which converts jade to html when you upload it to S3. – Lakshman Diwaakar Jan 10 '17 at 09:50
  • @ApurvaG did you find out the work around for hosting jade files in Google cloud storage? – Lakshman Diwaakar Jan 14 '17 at 06:23
  • No I haven't found out yet. Still looking for a solution – EdG Jan 14 '17 at 09:07
  • Side question: what if you want to interact with the NDB? Is this a job for Cloud Endpoints? – hyang123 Nov 04 '17 at 21:02
  • If NDB means nosql database, it has to be handled by some compute resources. Maybe you can use data store as NDB, do the CRUD operations from cloud functions, which is invoked by cloud endpoints rom the react app. – Lakshman Diwaakar Nov 05 '17 at 01:50