MongoDB and Node.js are often used together because of their shared use of Javascript and its Object Notation (JSON). Mongoose is a popular helper library that provides a more rigorous modeling environment for your data, enforcing a little bit more structure as needed, while still maintaining flexibility that makes MongoDB powerful. In this article, you make a connection to a hosted MongoDB instance at add-on provider MongoLab with Mongoose and model a simple object.
To deploy the app to Heroku you can use the Heroku button or follow these steps:
git clone git://github.com/mongolab/hello-mongoose.git && cd hello-mongoose
heroku create
heroku addons:add mongolab
git push heroku master
heroku open
The app can be debugged and tested using the Heroku Docker CLI plugin.
Make sure the plugin is installed:
heroku plugins:install heroku-docker
Configure Docker and Docker Compose:
heroku docker:init
And run the app locally:
docker-compose up
The app will now be available on the Docker daemon IP on port 8080.
You can also use Docker to release to Heroku:
heroku create
heroku docker:release
heroku open
MIT Licensed