DEV Community

Cover image for Deploying a React-based application on Google Cloud Platform
Rossano D'Angelo
Rossano D'Angelo

Posted on • Updated on

Deploying a React-based application on Google Cloud Platform



GCP offers a wide range of tools (like App Engine, Cloud Functions, Datastore, etc) that make it easier deploying serverless applications.

In this article, I'll talk about setting up a React application to be deployed on Google Cloud platform using App Engine and about storing my code on Google Cloud Source Repositories.

Create the React project

First, I create a new React project

npx create-react-app looney-tunes
cd looney-tunes
npm start
Enter fullscreen mode Exit fullscreen mode

Create the new project on GCP

Now I setup the project on Google Cloud Platform

Alt Text

Install gcloud

I have to install gcloud CLI to interact with the project from my machine.

For Mac OS, download the .tar.gz file at and extract it. Then run ./google-cloud-sdk/

Once reloaded the terminal, I run gcloud -v to check the installation

Google Cloud SDK 279.0.0
bq 2.0.53
core 2020.01.31
gsutil 4.47
Enter fullscreen mode Exit fullscreen mode

Init gcloud

In the root folder of the React project I run gcloud init to initialize the project for GCP. Following the interactive CLI, I can setup the project

Alt Text

Alt Text

Setup the new remote for the repository and push

It's time to create my repository for this initial code. I search cloud repositories via the search bar

Alt Text


Alt Text

Click Add repository on the right-top corner. Then select Create new repository. Now I choose a name for my repository )project's name) and I select the GCP project

Alt Text

At this point, make sure Push code from a local Git repository is selected. I use the SSH authentication to push my code. From the root folder of the React project, I run

git remote add google ssh://
git push --all google
Enter fullscreen mode Exit fullscreen mode

Error. Probably due to the missing API Key. I create a new API Key and I add it to my Cloud Source Repositories

Once done, I run git push --all google once again to push my code.

Alt Text

Create the app.yaml file

To make Google Cloud Platform able to deploy the project, I add a new file in the root folder of the project: app.yaml

# Copyright 2017, Google, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.
# [START app_yaml]
env: flex
runtime: nodejs
# [END app_yaml]
Enter fullscreen mode Exit fullscreen mode

I save and push

Alt Text

Alt Text


Everything is ready! In the root folder of the project, I run gcloud app deploy. I select the region of the project (in my case, europe-west2)

Alt Text

The console prompts the following message

Services to deploy:

descriptor:      [/Users/rossanodan/Desktop/Development/looney-tunes/app.yaml]
source:          [/Users/rossanodan/Desktop/Development/looney-tunes]
target project:  [looney-tunes-267812]
target service:  [default]
target version:  [20200210t131032]
target url:      []
Enter fullscreen mode Exit fullscreen mode

This is a preview of what is going to be deployed and published. I enter Y.


Once the project is deployed, I run gcloud app browse that opens

Top comments (1)

andyoh365 profile image
Andy Oh

Why is Cloud Source repo necessary? Is it possible to deploy without it?