To run the application in development mode on your localhost follow the following steps:
- Go to the backend directory and install node modules
cd backend
npm i
- Go to /app/config directory in the backend directory and change the env.json to the following lines
{
"backend": {
"ip": "http://localhost",
"port": 8080
},
"frontend": {
"ip": "http://localhost",
"port": 80
}
}
- Run the following command inside /backend directory to start the backend server
cd backend
npm start
- Go to the frontend directory and install node modules
cd frontend
npm i
- Go to /src/config directory in the frontend directory and change the env.json to the following lines
{
"backend": {
"ip": "http://localhost",
"port": 8080
},
"frontend": {
"ip": "http://localhost",
"port": 80
}
}
- Run the following command in /frontend directory to start the frontend server
cd frontend
npm start
- Configure your terminal/ powershell/ command prompt to use your GCP project
gcloud init
-
Configure the create-cluster.sh script file with your GCP project name instead of "pragmatic-armor-334222" in all places it is given or use the GUI in cloud platform console to create a cluster.
-
Edit the above 2 env.json files with IP address of the load balancer you created instead of http://localhost
-
Run the cloud build command on terminal inside both the frontend and backend directories (direcotry in which Dockerfile is present) to build and push to your project's container registry.
gcloud builds submit --tag gcr.io/<your-project-ID>/<image-name-you-want>
- Edit and run the deployment and service yaml files.
See the create-cluster.sh file you edited and ran for the cluster name and zone "whiteboard-cluster" and "us-central1-c" in our case.
Change the containers' image attribute to names of the containers in your source repository.
gcloud container clusters get-credentials <your-cluster-name> --zone <zone-where-you-deployed>
kubectl apply -f gke-deployment.yaml
kubectl apply -f gke-service.yaml
-
That's all, your application is live.
-
To find the IP address go to GCP console, Google Kubernetes Engine, Services and Ingress, click on the name of your service, scroll down and find the external endpoints.
<ip-address>:80
for frontend
<ip-address>:8080
for backend
Click on <ip-address>
:80 to see the live application