{"id":40,"date":"2023-01-10T01:28:30","date_gmt":"2023-01-10T06:28:30","guid":{"rendered":"https:\/\/shagun.dev\/?p=40"},"modified":"2025-01-08T20:53:14","modified_gmt":"2025-01-09T01:53:14","slug":"how-to-host-website-in-gcp","status":"publish","type":"post","link":"https:\/\/shagun.dev\/?p=40","title":{"rendered":"How to host website using GCP"},"content":{"rendered":"\n<p>GCP Service Used : Cloud Storage<\/p>\n\n\n\n<p>1. Create a project in GCP<\/p>\n\n\n\n<p>2. Under that project, go to view all services. Look for <br>Storage &gt; Cloud &gt; Buckets<\/p>\n\n\n\n<p>3. Create New Bucket named as test_gcp-01<br> Select Location-Type as Multi-region<\/p>\n\n\n\n<!--more-->\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"548\" src=\"https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-12.58.35-AM-1024x548.png\" alt=\"\" class=\"wp-image-43\" srcset=\"https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-12.58.35-AM-1024x548.png 1024w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-12.58.35-AM-300x160.png 300w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-12.58.35-AM-768x411.png 768w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-12.58.35-AM-1536x822.png 1536w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-12.58.35-AM-2048x1095.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>4. Choose all the by default setting and Create<\/p>\n\n\n\n<p> 5. Confirm the public access prevention<\/p>\n\n\n\n<p>6. Upload or drag build folder files. If react app, run these commands to get production code<br>      <code>npm install<\/code><br>      <code>npm run build<\/code><\/p>\n\n\n\n<p>7. Create a new file named as app.yaml and placed under src folder of the project.<br><br><code>runtime: nodejs10<br>handlers:<br>#Serve all static files with urls ending with a file extension<br>- url: \/(.*\\..+)$<br>static_files: build\/\\1<br>upload: build\/(.*\\..+)$<br>#catch all handler to index.html<br>- url: \/.*<br>static_files: build\/index.html<br>upload: build\/index.html<\/code><\/p>\n\n\n\n<p>8. Upload the app.yaml to the bucket<\/p>\n\n\n\n<p>9. The final uploads looks like:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"521\" src=\"https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-1.11.52-AM-1024x521.png\" alt=\"\" class=\"wp-image-42\" srcset=\"https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-1.11.52-AM-1024x521.png 1024w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-1.11.52-AM-300x153.png 300w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-1.11.52-AM-768x391.png 768w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-1.11.52-AM-1536x782.png 1536w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-1.11.52-AM-2048x1043.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>10. Activate Cloud Shell from the top bar placed near to search bar<br>Write following commands: <br><code>gcloud config set project your-project-name<br>mkdir react-app<br>gsutil rsync -r gs:\/\/gcp.shagun.dev .\/react-app<br>cd react-app<br>gcloud app deploy<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"291\" src=\"https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-1.18.14-AM-1-1024x291.png\" alt=\"\" class=\"wp-image-45\" srcset=\"https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-1.18.14-AM-1-1024x291.png 1024w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-1.18.14-AM-1-300x85.png 300w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-1.18.14-AM-1-768x219.png 768w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-1.18.14-AM-1-1536x437.png 1536w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-1.18.14-AM-1-2048x583.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>11. Please check Deployed service in the screenshot, copy the given link and paste it to browser<br>12. Your website got live !<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GCP Service Used : Cloud Storage 1. Create a project in GCP 2. Under that project, go to view all services. Look for Storage &gt; Cloud &gt; Buckets 3. Create New Bucket named as test_gcp-01 Select Location-Type as Multi-region<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-40","post","type-post","status-publish","format-standard","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/shagun.dev\/index.php?rest_route=\/wp\/v2\/posts\/40","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shagun.dev\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shagun.dev\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shagun.dev\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shagun.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=40"}],"version-history":[{"count":13,"href":"https:\/\/shagun.dev\/index.php?rest_route=\/wp\/v2\/posts\/40\/revisions"}],"predecessor-version":[{"id":140,"href":"https:\/\/shagun.dev\/index.php?rest_route=\/wp\/v2\/posts\/40\/revisions\/140"}],"wp:attachment":[{"href":"https:\/\/shagun.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=40"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shagun.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=40"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shagun.dev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=40"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}