I created this simple SpringBoot application for experimenting Cloud Run and Cloud Datastore platforms.
CloudRun is a serverless computing platform for deploying and scaling containerized applications quickly and securely.
Cloud Datastore is a NoSQL document database built for automatic scaling, high performance, and ease of application development.
Spring Cloud GCP is one of the sub projects of Spring Cloud providing tools for developers to quickly build some of the common patterns in distributed systems (e.g. configuration management, service discovery). It helped me a lot while developing Google Cloud Platform (GCP) applications with Spring Framework by providing auto-configuration facilities.
-
Login to your GCP(Google Cloud Platform) account.
-
Install Google Cloud SDK to your local machine.
-
Create a project in the console. See this link for how to create and manage projects.
-
Make sure we are pointing to the correct project and authenticate using following commands:
gcloud config set project <YOUR PROJECT ID> gcloud auth login
-
Make sure your machine has app credentials to run your app.
gcloud auth application-default login
-
Run your application locally
mvn spring-boot:run
Follow first 5 steps above and run following command
mvn jib:build
This command will build and push your image to your GCR (Google Cloud Registery) automatically. Then you need to create a new Cloud Run service in the console and select your uploaded image. Now your endpoints are ready!
Note: You dont need Docker installed on your machine since we have jib dependency. It is a great way to containerize your Java application. It allows you to create optimized images without Docker using Maven or Gradle.
Get all records (HTTP : GET)
{YOUR_CLOUDRUN_SERVICE_URL}/api/todo/all
Get single record (HTTP : GET)
{YOUR_CLOUDRUN_SERVICE_URL}/api/todo/get/{id}
Save new record (HTTP : POST)
{YOUR_CLOUDRUN_SERVICE_URL}/api/todo/save
Update single record (HTTP : POST)
{YOUR_CLOUDRUN_SERVICE_URL}/api/todo/update
Delete single record (HTTP : GET)
{YOUR_CLOUDRUN_SERVICE_URL}/api/todo/delete/{id}
- Add a UI (VueJS)
- Secure the endpoints with Okta
Feel free to contact me on github or follow me on [twitter] (https://twitter.com/mr_genco). :)