A simple full stack cloud app you can reference to build your own cloud ready app!
- Backend (REST API): database/src/main/java/io/clouddemo/storage/rest
- Frontend: database/src/main/webapp
- An account on IBM Cloud
- An IBM Cloudant instance - IBM Cloud Platform Instructions or CLI Instructions
- A non-partitioned Cloudant database in your Cloudant instance
- Docker
- Java
- Git
- Maven
git clone https://github.com/cloudreadyapp/hello_cloud_demo.git
cd hello_cloud_demo
mvn -f database install
mvn -f database liberty:package
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.
http://localhost:9080/HelloCloudDemoProject
docker stop hello_cloud_demo
docker rm hello_cloud_demo
docker image rm --force simple_database_microservice
docker system prune -f
mvn clean
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.
"first_name"
, eg. "Sam""last_name"
, eg. "Cloud""email"
, eg. "samcloud@cloudready.app"
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"
}'
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"}
Code in this project is licensed under the Apache License, Version 2.0. View the license here.