Sign inSign up

ageapps/docker-node-mongo

By ageapps

•Updated almost 8 years ago

Basic dockerized server using Node and MongoDB.

Image
1

2.7K

ageapps/docker-node-mongo repository overview

⁠docker-node-mongo

Basic dockerized server using Node and MongoDB. It shows through a simple example following MVC architecture the basic setup needed to build a server with docker and connect from node Node.js server to MongoDB.

Following the Microservices architecture⁠, the system consists on two services that run in separate containers:

⁠Demo

Yo can find a demo, working here⁠

⁠Using MongoDB replica sets

You just need to use the docker-compose.rps.yml compose file:

$ docker-compose -f docker-compose.rps.yml up
// connect in your browser to <host IP>:8080

⁠Usage with git

Downloading the source code

$ git clone https://github.com/ageapps/docker-node-mongo.git
$ cd docker-node-demo
$ docker-compose up
// connect in your browser to <host IP>:8080

⁠Usage with docker-compose, without source code

Just download docker-compose file to pull all images and build the app.

// download docker-compose file
$ curl https://raw.githubusercontent.com/ageapps/docker-node-mongo/master/docker-hub-compose.yml -o docker-compose.yml
// run application
$ docker-compose up
// connect in your browser to <host IP>:8080

⁠Usage with Docker Hub

No download needed, images will pull automatically.

// run mongo service
$ docker run -v "$(pwd)"/database:/data --name mongo_db -d mongo mongod --smallfiles
// run docker-node-mongo image
$ docker run -d --name node_server --link mongo_db:db -p 8080:3000 ageapps/docker-node-mongo
// connect in your browser to <host IP>:8080

⁠Usage in a cluster with k8s

Try running it in minikube⁠ with the following commands

$ minikube start --vm-driver=xhyve
$ kubectl config use-context minikube
$ eval $(minikube docker-env)
$ docker pull mongo
$ kubectl create -f k8s-mongo.yml
$ docker build -t node-mongo:v1 .
$ kubectl create -f k8s-app.yml
// to clean the cluster and get docker local context
$ kubectl delete -f .
$ eval $(minikube docker-env -u) 

⁠Resources

Tag summary

Content type

Image

Digest

Size

30.8 MB

Last updated

almost 8 years ago

docker pull ageapps/docker-node-mongo