Skip to content

Dockerized Node.js API, MongoDB database, and Ngnix reverse proxy with room for acme (letsencrypt) companion.

Notifications You must be signed in to change notification settings

mobiusdickus/nodejs-mongodb-nginx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js, MongoDB, and Nginx with Docker

Dockerized template for a Node.js API, MongoDB database, and served by a Ngnix reverse proxy with considerations for the acme (letsencrypt) companion for HTTPS.

*This project is by default set up for a development environment and will require some changes for a more production like environment.

Set Up

  1. Install docker and docker-compose.

Optional

By default I have set the VIRTUAL_HOST to localhost, so when you run this project you can access the app without having to change anything locally.

I would highly encourage you to read the nginx-proxy repo documentation for more detailed information about setting this up in a more production like environment.

TLDR; To set up this app with a custom domain, follow the steps below.

  1. Update the VIRTUAL_HOST in the docker-compose.yml to whatever hostname you want.
    • i.e. somedomain.local
  2. Add your chosen hostname to the /etc/hosts file on your local machine, and point it to localhost.
    • e.g. 127.0.0.1 somedomain.local

Development

  • For detached mode, run:
  • For detached mode, run:
    docker-compose up -d
  • For attached mode, run:
    docker-compose up

Since this is a development template, the nodejs container has a linked volume to detect changes and the nodejs container runs the nodemon command for code auto detection and process restart.

If you want to run this in a more production like environment, you will want to remove the volume parameter from the nodejs service in the docker-compose.yaml and change the nodejs service ENVIRONMENT to prod.

Comments

  • Look at the Makefile for other useful commands.
  • If you have a registered domain, replace VIRTUAL_HOST and localhost to said domain, and add the acme companion for HTTPS.
    • Read the nginx-proxy repo documentation for more information on how to configure HTTPS.

About

Dockerized Node.js API, MongoDB database, and Ngnix reverse proxy with room for acme (letsencrypt) companion.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published