Deploying from WebStorm on CLI to Google CloudRun
FOLLOW THESE DIRECTIONS to Deploy from Source Code to Google CloudRun.
In this example deploying a NodeJS+Express project from WebStorm into Google CloudRun
NOTE: any web service should be listening at port 8080 by default with Google Cloud Run
Prerequisites:
1) Have created a NodeJS + Express project in Webstorm
2) Have Google Cloud Account and setup a project in it and have a billing account associated with it (and you have put in your google cloud credits you were given for use to pay --DO NOT give a credit card,only use the free credits you were given at start of class).
3) Have the Google Cloud Command Line tool installed on your local machine
To Deploy In the Terminal window of your Webstorm project type in the command line command to deploy gcloud run deploy
Windows PowerShell PS C:\Users\lynne\WebstormProjects\ShoppingCartNodeExpress> gcloud run deploy Service name (shoppingcartnodeexpress): To make this the default region, run `gcloud config set run/region us-central1`. This command is equivalent to running `gcloud builds submit --pack image=[IMAGE] C:\Users\lynne\WebstormProjects\ShoppingCartNodeExpress` and `gcloud run deploy shop Allow unauthenticated invocations to [shoppingcartnodeexpress] (y/N)? y Building using Buildpacks and deploying container to Cloud Run service [shoppingcartnodeexpress] in project [autoguide-324523] region [us-central1] |
Follow the instructions again and answer the prompts (again see Deploy from Source Code to Google CloudRun.) --> at the end you will be given a URL that has your deployed app. Here it the results of me running the main / path to this url
Important: Remove your application from Google CloudRun when not using (but, means will need to redeploy when you want it to be available)
From Google, "While Cloud Run does not charge when the service is not in use, you might still be charged for storing the container image in Artifact Registry. You can delete your container image or delete your Google Cloud project to avoid incurring charges. Deleting your Google Cloud project stops billing for all the resources used within that project." ......THERE ARE 2 OPTIONS LISTED BELOW
OPTION 1: REMOVE CONTAINER IMAGE IN REGISTRY + REMOVE SERVICE
STEP 1.1) Remove Service
Deleting existing services
The following considerations apply to deleting a service:
- Deleting a service deletes all resources related to this service, including all revisions of this service whether they are serving traffic or not.
- Deleting a service does not automatically remove container images from Container Registry. To delete container images used by the deleted revisions from Container Registry, refer to Deleting images.
- Deleting a service with one or more Eventarc triggers does not automatically delete these triggers. To delete the triggers refer to Manage triggers.
- After deletion, the service remains visible in the Google Cloud console and in the command line interface until the deletion is fully complete. However, you cannot update the service.
-
Deleting a service is permanent: there is no undo or restore. However, if after deleting a service, you deploy a new service with the same name in the same region, it will have the same endpoint URL.
To delete a service:
-
Locate the service you want to delete in the services list, and click its checkbox to select it.
-
Click DELETE. This deletes all revisions of the service.
Example before & after deletion of my service deployed above
STEP 1.2) Remove REGISTRY
-
select project, go to Artifact Registery, select it and hit Delete
OPTION 2: Remove your project (only do this if you don't need the project)
-
Caution: Deleting a project has the following effects:
- Everything in the project is deleted. If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.
- Custom project IDs are lost. When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as an appspot.com URL, delete selected resources inside the project instead of deleting the whole project.
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.