Node.js Express and MongoDB REST API sample application.
1.4K
$ docker run --name myNodeApp -d nodeapp:tag
The container runs on the default port 5000.
You can change it by setting the environment variable PORT to the desired value.
This version of the nodeapp image is a simple Node.js Express application.
docker run --name myContainer -p 5000:5000 reyanshkharga/nodeapp:v1
GET /
GET /health
GET /random
GET / returns a JSON object containing Host and Version.
GET /health returns the health status.
GET /random returns a random integer between 1 and 10
This version of the nodeapp image is the same as the v1. The only change is that the Express server starts after a delay of 30s.
This version of the nodeapp image intermittently throws a 502 error intentionally. This version is created to demo the circuit breaker feature of Istio.
This version of the nodeapp image uses MongoDB to store data.
MONGODB_URI
POD_NAME
MONGODB_URI is required while POD_NAME is optional.
# without environment variable
docker run --name myContainer --env -p 5000:5000 reyanshkharga/nodeapp:mongo
# with environment variable
docker run --name myContainer --env POD_NAME=myPod MONGODB_URI=mongodb://my-mongodb-service:27017 -p 5000:5000 reyanshkharga/nodeapp:mongo
GET /
GET /health
GET /random
GET /books
POST /addBook
POST /updateBook
POST /deleteBook
GET / returns a JSON object containing Host and Version. If the POD_NAME environment variable is set, the value of the Host will be the value of the variable.GET /health returns the health status.GET /random returns a randomly generated number.GET /books returns the list of books.POST /addBook adds a book.POST /updateBook updates the copies_sold value for the given book id.POST /deleteBook deletes the book record that matches the given id.Sample body for POST /addBook:
{
"id": 1,
"title": "Book1",
"copies_sold": 0
}
Sample body for POST /updateBook:
{
"id": 1,
"copies_sold": 100
}
Sample body for POST /deleteBook:
{
"id": 1
}
Content type
Image
Digest
sha256:8c6288590…
Size
44.3 MB
Last updated
4 months ago
docker pull reyanshkharga/nodeapp:probes