Skip to content

A simple SpringBoot application with Cloud Run and Cloud Datastore

Notifications You must be signed in to change notification settings

mrgenco/serverless-todo-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Background

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.

Setup for local machine :

  1. Login to your GCP(Google Cloud Platform) account.

  2. Install Google Cloud SDK to your local machine.

  3. Create a project in the console. See this link for how to create and manage projects.

  4. Make sure we are pointing to the correct project and authenticate using following commands:

    gcloud config set project <YOUR PROJECT ID>
    gcloud auth login
  5. Make sure your machine has app credentials to run your app.

    gcloud auth application-default login
  6. Run your application locally

    mvn spring-boot:run

Setup for Cloud 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.

Endpoints

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}

TODOS :

  • Add a UI (VueJS)
  • Secure the endpoints with Okta

Any Questions or Want to be Friends?

Feel free to contact me on github or follow me on [twitter] (https://twitter.com/mr_genco). :)

About

A simple SpringBoot application with Cloud Run and Cloud Datastore

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages