Skip to content

cloudreadyapp/hello_cloud_demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello Cloud Demo

A simple full stack cloud app you can reference to build your own cloud ready app!


Step-by-step on how to deploy the hello_cloud_demo app with IBM Cloud, Docker and Kubernetes:


How to build and run the project locally

Pre-requisites

System pre-requisites

  • Docker
  • Java
  • Git
  • Maven

Clone or Fork the project

git clone https://github.com/cloudreadyapp/hello_cloud_demo.git
cd hello_cloud_demo

Build and run project as docker container

[1] Install required libraries

mvn -f database install

[2] Install required maven packages

mvn -f database liberty:package

[3] Build and run docker container as a microservice

docker pull open-liberty
docker build -t simple_database_microservice database
docker run -d --name hello_cloud_demo -p 9080:9080 -e cloudantapikey="<insert cloudant api key>" -e cloudantendpoint="<insert cloudant database endpoint url>" -e cloudantdbname="<insert cloudant database name>" simple_database_microservice

Take note of the outputted docker <imageID> so you can delete it later once you're done. If you lose it, you can do docker ps -a to list all running docker images.

[4] View the running app!

http://localhost:9080/HelloCloudDemoProject

[5] Stop container

docker stop hello_cloud_demo

[6] Erase containers and clean project

docker rm hello_cloud_demo
docker image rm --force simple_database_microservice
docker system prune -f
mvn clean

Making requests to the database

Here are some sample cURL requests to send/retrieve data to/from our database. These requests are based on a locally-run backend (i.e. localhost:9080).

You can also use Hoppscotch or Postman to make HTTP requests.

DemoDocument fields

Sample POST request

curl -X POST \
  'http://localhost:9080/HelloCloudDemoProject/demo/database/store' \
  -H 'Content-Type: application/json; charset=utf-8' \
  -d '{
    "first_name": "Sam",
    "last_name": "Cloud",
    "email": "samcloud@cloudready.app"
  }'

Sample GET request

curl -X GET \
  'http://localhost:9080/HelloCloudDemoProject/demo/database/retrieve?first_name=Sam&last_name=Cloud'

Response:

{"email":"samcloud@cloudready.app","first_name":"Sam","last_name":"Cloud"}

License

Code in this project is licensed under the Apache License, Version 2.0. View the license here.

About

A simple full stack cloud app you can reference to build your own cloud ready app!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published