<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Divyansh Gothwal</title>
    <description>The latest articles on Forem by Divyansh Gothwal (@divyanshgothwal).</description>
    <link>https://forem.com/divyanshgothwal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F232908%2F259930ad-19e4-4d1a-ba14-d0490869e444.jpeg</url>
      <title>Forem: Divyansh Gothwal</title>
      <link>https://forem.com/divyanshgothwal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/divyanshgothwal"/>
    <language>en</language>
    <item>
      <title>Polyfill for ReactDOM.render</title>
      <dc:creator>Divyansh Gothwal</dc:creator>
      <pubDate>Sat, 10 Jun 2023 20:07:10 +0000</pubDate>
      <link>https://forem.com/divyanshgothwal/polyfill-for-reactdomrender-551n</link>
      <guid>https://forem.com/divyanshgothwal/polyfill-for-reactdomrender-551n</guid>
      <description>&lt;p&gt;In this article we are going to build a polyfill for ReacDOM.render() before react18 or ReactDOM.createRoot(${domElement}).render(${reactElement})&lt;/p&gt;

&lt;p&gt;To do this we need to understand how reactElement is represent by react.&lt;/p&gt;

&lt;p&gt;we have 3 cases&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// case 1
let jsx1 = &amp;lt;div&amp;gt;Test&amp;lt;/div&amp;gt;;
let reactElemen1 = { type: "div", props: { children: "Test" } };

// case 2
let jsx2 = (
  &amp;lt;div&amp;gt;
    &amp;lt;h1&amp;gt;Test&amp;lt;/h1&amp;gt;
  &amp;lt;/div&amp;gt;
);
let reactElemen2 = {
  type: "div",
  props: { children: { type: "h1", props: { children: "Test" } } }
};

// case 3
let jsx3 = (
  &amp;lt;div&amp;gt;
    &amp;lt;h1&amp;gt;TestH1&amp;lt;/h1&amp;gt;
    &amp;lt;h2&amp;gt;TestH2&amp;lt;/h2&amp;gt;
  &amp;lt;/div&amp;gt;
);
let reactElemen3 = {
  type: "div",
  props: {
    children: [
      { type: "h1", props: { children: "TestH1" } },
      { type: "h2", props: { children: "TestH2" } }
    ]
  }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we understand how a react element can look like.&lt;br&gt;
Lets start coding a function which takes reactElement and domNode, then renders all the react element as child of domNode.&lt;br&gt;
Below the recursive code for this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// function for setting styles for an elemement
function setStyle(domNode, styles) {
  Object.keys(styles ?? {}).forEach((styleKey: any) =&amp;gt; {
    domNode.style[styleKey] = styles[styleKey];
  });
}

// main function for rendering reactElement to domNode
export function render(reactElement, domNode) {
  const {
    type,
    props: { children, style }
  } = reactElement;
  // first create a domElement from using type.
  let createdElement = document.createElement(type);
  //setting styles
  setStyle(createdElement, style);
  // checking if children is array
  if (Array.isArray(children)) {
    children.forEach((child) =&amp;gt; {
      createdElement = render(child, createdElement);
    });
  // if children is object type
  } else if (typeof children === "object") {
    createdElement = render(children, createdElement);
  } else {
    // if children is of type string
    createdElement.innerHTML = children;
  }
  // append createdElement to domNode. 
  domNode.appendChild(createdElement);
  return domNode;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the codesandbox for this.&lt;br&gt;
&lt;a href="https://codesandbox.io/s/polyfill-for-react-renderer-bpcc3z?file=/src/index.tsx"&gt;custom renderer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There you go you have created your basic custom renderer which renders reactElement to domNode.&lt;/p&gt;

&lt;p&gt;Obviously we have not handled Component types but that i will   covering in next article.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>setInterval Gotchas with React Hooks</title>
      <dc:creator>Divyansh Gothwal</dc:creator>
      <pubDate>Thu, 25 May 2023 17:39:09 +0000</pubDate>
      <link>https://forem.com/divyanshgothwal/settimeout-gotchas-with-react-hooks-1c5j</link>
      <guid>https://forem.com/divyanshgothwal/settimeout-gotchas-with-react-hooks-1c5j</guid>
      <description>&lt;p&gt;In this article we are going to understand Gotchas of using setInterval callback function to update state.&lt;/p&gt;

&lt;p&gt;For example we have to build a react where we start timer when application loads.&lt;/p&gt;

&lt;p&gt;Below the code that everyone who has basic knowledge react will write it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function WrongCountUpdate() {
  const [count, setCount] = useState(0);

  useEffect(() =&amp;gt; {
    const timer = setInterval(() =&amp;gt; {
      setCount(count + 1);
    }, 1000);

    return () =&amp;gt; clearInterval(timer);
  }, []);

  return &amp;lt;div&amp;gt;Wrong count update: {count}&amp;lt;/div&amp;gt;;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is bug in the above code and this has nothing to do with react this is how javascript works.&lt;br&gt;
let's have a look at this live.&lt;br&gt;
Below is the Codesandbox link for this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/s/updating-state-with-hooks-ssm7qh"&gt;Counter update&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's see why this code is not correct?&lt;/p&gt;

&lt;p&gt;Below is the flow of this react component.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Component mounts/renders &lt;/li&gt;
&lt;li&gt;UseEffect will be called which sets setInterval with a callback function.&lt;/li&gt;
&lt;li&gt;When setInterval is executed with callback function, it has closure with value of count=0.&lt;/li&gt;
&lt;li&gt;When state updates setInterval callback function is not aware of change of count variable and its closure still has value of count=0 and when setCount is executed with 0+1 ==&amp;gt; 1 thus our count is always one.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To fix this issue we just have to make one change in our setCount instead of passing value to it, we pass a callback function whose input argument is previous count value and return new state.&lt;/p&gt;

&lt;p&gt;React ensures that argument of this function has correct previous value.&lt;/p&gt;

&lt;p&gt;Below is the correct code for this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function CorrectCountUpdate() {
  const [count, setCount] = useState(0);

  useEffect(() =&amp;gt; {
    const timer = setInterval(() =&amp;gt; {
      setCount((prevCount) =&amp;gt; prevCount + 1);
    }, 1000);

    return () =&amp;gt; clearInterval(timer);
  }, []);

  return &amp;lt;div&amp;gt;Correct count update: {count}&amp;lt;/div&amp;gt;;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>react</category>
      <category>typescript</category>
      <category>stinterval</category>
    </item>
    <item>
      <title>Creating CI/CD pipeline using triggers of google cloud for web app written in Spring Boot(java) and React.js</title>
      <dc:creator>Divyansh Gothwal</dc:creator>
      <pubDate>Tue, 14 Jul 2020 12:22:56 +0000</pubDate>
      <link>https://forem.com/divyanshgothwal/creating-ci-cd-pipeline-using-triggers-of-google-cloud-for-web-app-written-in-spring-boot-java-and-react-js-gj7</link>
      <guid>https://forem.com/divyanshgothwal/creating-ci-cd-pipeline-using-triggers-of-google-cloud-for-web-app-written-in-spring-boot-java-and-react-js-gj7</guid>
      <description>&lt;p&gt;Hello all😊👋&lt;br&gt;
This is my first post so bear with me.&lt;/p&gt;

&lt;p&gt;In this article, I am going to tell you guys how I was able to automate the testing, building and deployment(on GCP &lt;strong&gt;APP ENGINE&lt;/strong&gt;) of my web app written in &lt;strong&gt;React&lt;/strong&gt; and &lt;strong&gt;Spring Boot&lt;/strong&gt; ( code base on GitHub) using google cloud trigger.&lt;/p&gt;
&lt;h2&gt;
  
  
  Contents of this Article
&lt;/h2&gt;

&lt;p&gt;1) Directory structure I used.&lt;br&gt;
2) Configuring GCP trigger to listen to GitHub commits of a repository.&lt;br&gt;
3) Understanding different configuration files required.&lt;br&gt;
4) Deploying frontend and backend as different service to GCP APP Engine&lt;br&gt;
5) Serving frontend and backend from two different services on the same domain.&lt;/p&gt;
&lt;h3&gt;
  
  
  1) Directory structure:
&lt;/h3&gt;

&lt;p&gt;Below is the directory structure I am using to fulfil my requirement of testing, building and deploying &lt;strong&gt;UI&lt;/strong&gt; and &lt;strong&gt;Server&lt;/strong&gt; on a GitHub commit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkbrnlfr4czd5epu903ht.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkbrnlfr4czd5epu903ht.PNG" alt="Alt root directory structure"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  2) Configuring GCP trigger to listen to GitHub commits of a repository
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to your GCP console&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new project named web-app, you can give any name but here I will use web-app&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyh15frg5axvxirphuhex.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyh15frg5axvxirphuhex.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once project is created, select that project and go to triggers as mentioned in below.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkvnr88fsda7tvi42bfn8.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkvnr88fsda7tvi42bfn8.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once you are in triggers page you will see &lt;strong&gt;Connect Repository&lt;/strong&gt; as shown below, this connect the trigger to a particular branch(my case it was a master branch) of GitHub repository and once connected it will listen to GitHub commits on that branch.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Below screenshots explains the steps to connect a branch from GitHub to your GCP projects trigger.&lt;/p&gt;

&lt;p&gt;a)&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwm23pxq4v3k30s9ueh0s.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwm23pxq4v3k30s9ueh0s.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;b)&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffo1h380fiwb5eokr9khc.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffo1h380fiwb5eokr9khc.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;c) First, you have to &lt;strong&gt;add a new account&lt;/strong&gt;, once the GitHub account is added then click on &lt;strong&gt;Edit repositories on GitHub&lt;/strong&gt;, which will redirect you to GitHub where it will ask you for repositories to select for which trigger will listen.&lt;br&gt;
d) Once Trigger created you can see the details of the trigger.&lt;br&gt;
Currently below are the configuration of my trigger&lt;br&gt;
       * Event: Push to any branch&lt;br&gt;
       * Status: Enabled&lt;br&gt;
       * Build Configuration: Auto-Detected&lt;br&gt;
You can edit these configurations&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdw45io0j0eh7czv6l9qd.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdw45io0j0eh7czv6l9qd.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, your trigger is connected to your GitHub repo but before we commit anything to this repository we need to understand the configuration file required to test, build and deploy our app to &lt;strong&gt;APP Engine&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  3) Understanding different configuration files required.
&lt;/h3&gt;

&lt;p&gt;We need to create few scripts which will be picked up by GCP triggers to build and deploy our app to GCP &lt;strong&gt;APP ENGINE&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;cloudbuild.yaml&lt;/strong&gt;: It is picked up and executed by GCP triggers on every GitHub commit. It should be present in the root of our project directory. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;app.yaml&lt;/strong&gt;: This is the file used for deploying our web-app to GCP &lt;strong&gt;APP ENGINE&lt;/strong&gt; based on the configurations specified in it. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  4) Deploying frontend and backend as different service to GCP APP Engine
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://cloud.google.com/appengine/docs/standard/java/microservices-on-app-engine" rel="noopener noreferrer"&gt;Google recommends using microservices within an App engine&lt;/a&gt; project instead of building one monolith that serves all requests. So I’m going to have a front end service that uses the Node.js runtime and a back end service that uses the Java runtime.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deploying Backend&lt;/strong&gt;(Spring Boot java application) as new service&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For deploying Backend java application we will use docker.&lt;br&gt;
we will follow the below steps&lt;br&gt;
a) First, create a Docker image using below docker file&lt;br&gt;
b) push that image to GCP &lt;strong&gt;Container Registry&lt;/strong&gt;&lt;br&gt;
c) Deploying that image to GCP &lt;strong&gt;APP ENGINE&lt;/strong&gt; using below app.yaml file&lt;/p&gt;

&lt;p&gt;Below is my Docker file(present in server/Dockerfile)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM openjdk:8-alpine
VOLUME /tmp
ADD target/webapp-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;app.yaml file for backend deployment (present in server/src/main/appengine)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;env: flex
service: backend
instance_class: F1
handlers:
- url: /.*
  script: this field is required, but ignored
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deploying frontend&lt;/strong&gt; as a new service: 
 I am going to use Express.js to host my static files, below is the code to serve static files
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require('express');

const path = require('path');

const app = express();

// This code makes sure that every request that matches a static file in the
// build folder, it serves that file.
app.use(express.static(path.join(__dirname, 'build')));

// This code makes sure that any request that does not matches a static file
// in the build folder, will just serve index.html.
app.get('/*', (req, res) =&amp;gt; {
  res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

// Starting the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () =&amp;gt; {
  console.log(`App listening on port ${PORT}`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this, we will create the app.yaml file UI folder as shown below, But remember that package.json, start scripts should be &lt;strong&gt;node app.js&lt;/strong&gt; where app.js is having server-side code for serving static files.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fm6i624l0fv2bfsi4fa96.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fm6i624l0fv2bfsi4fa96.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;app.yaml file to deploy node.js application to host our static files&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;runtime: nodejs
# new service named default is created where frontend will hosted
service: default
env: flex
instance_class: F1
threadsafe: true
handlers:
  - url: /
    static_files: build/index.html
    upload: build/index.html
  - url: /
    static_dir: build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5) Serving frontend and backend from two different services on the same domain.
&lt;/h3&gt;

&lt;p&gt;To let Google’s load balancer decide what microservice needs to handle what request, you can define a &lt;a href="https://cloud.google.com/appengine/docs/standard/nodejs/reference/dispatch-yaml" rel="noopener noreferrer"&gt;dispatch.yaml&lt;/a&gt; file to &lt;a href="https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed#routing_with_a_dispatch_file" rel="noopener noreferrer"&gt;overwrite App Engine’s default routing rules&lt;/a&gt;. This has to be done after all independent services have started. My dispatch.yaml file looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dispatch:
# Route the URLs that point to the java backend to backend service
  - url: "*/test/v1/*"
    service: backend
# Route all other urls to the React.js frontend
  - url: "*/*"
    service: default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below is the final cloudbuild.yaml file(present in root directory of project) for frontend and backend steps to be executed by trigger&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# below are the spteps executed by trigger
steps:
# frontend deployment
# Step 1: For installing dependencies
  - name: "gcr.io/cloud-builders/npm"
    dir: 'ui'
    args: ["install"]

# Step 2: For creating optinimized build
  - name: "gcr.io/cloud-builders/npm"
    dir: 'ui'
    args: ["run", "build"]

# Step 3: This step will execute app.yaml in your ui folder and deploy your app based on the configuration specified
  - name: "gcr.io/cloud-builders/gcloud"
    dir: 'ui'
    args: ["app", "deploy"]
# timeout specified for this step as deployment may take more that default time(10min)
    timeout: "30m0s" 

# backend deployment
# Step 4: Running maven tests
  - name: maven:3-jdk-8
    entrypoint: mvn
    dir: 'server'
    args: ["test"]

# Step 5: Running **mvn clean install** and skipping test cases
  - name: maven:3-jdk-8
    entrypoint: mvn
    dir: 'server'
    args: ["clean", "install", "-Dmaven.test.skip=true"]

# Step 6: Creating docker image using docker file present in server folder
  - name: docker
    dir: 'server'
    args: ["build", "-t", "gcr.io/web-app/webapp3", "."]

# Step 7: pushing docker image to GCP Container Registry
  - name: "gcr.io/cloud-builders/docker"
    args: ["push", "gcr.io/web-app/webapp3"]

# Step 8: Deploying this image using app.yaml present in **server/src/main/appengine** to GCP **APP ENGINE**
  - name: 'gcr.io/cloud-builders/gcloud'
    dir: 'server/src/main/appengine'
    args: ['app', 'deploy', "--image-url=gcr.io/web-app/webapp3"]
    timeout: "30m0s"

# Step 9: This step is make sure that dispatch.yaml file is deployed once all the services are started
  # dispatch.yaml deployment
  - name: "gcr.io/cloud-builders/gcloud"
    args: ["app", "deploy", "dispatch.yaml"]
    timeout: "30m0s"
timeout: "100m0s"
images: ["gcr.io/web-app/webapp3"]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;once all services are started you can go to GCP &lt;strong&gt;APP ENGINE&lt;/strong&gt; and see the deployed services and path the dispatch routes like below:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6rspv286sz8q7t7a6z07.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6rspv286sz8q7t7a6z07.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Now you can go ahead and commit to your GitHub repository.
&lt;/h4&gt;

&lt;p&gt;Go to you &lt;strong&gt;Cloud build&lt;/strong&gt;-&amp;gt;&lt;strong&gt;History&lt;/strong&gt; and you see can build started.&lt;/p&gt;

&lt;p&gt;once build is successfully completed then below is the screenshot you can see.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fv55ps8oqiogos9abekrr.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fv55ps8oqiogos9abekrr.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Hurray you have successfully deployed you web-app to google cloud.
&lt;/h2&gt;

&lt;p&gt;If you have come this far reading this article, please provide your valuable comment or feedback so that I can improve next time. &lt;/p&gt;

&lt;p&gt;Happy Reading !!&lt;/p&gt;

</description>
      <category>java</category>
      <category>javascript</category>
      <category>googlecloud</category>
      <category>react</category>
    </item>
  </channel>
</rss>
