Code Monkey home page Code Monkey logo

node-docker-demo's Introduction

Docker Demo Application With Node & Express

How To Run



libraries and other modules used


  • Node
  • Express
  • Express Session
  • Cors
  • Nodemon
  • Bcrypt
  • Redis
  • Mongo DB
  • Mongoose
  • Docker
  • Docker Compose

Important Tasks


Create Simple Node And Express Application

  • Node init
  • Add Express

Create Dockerfile

  • FROM
  • WORKDIR
  • COPY
  • ARG
  • RUN
  • COPY
  • ENV
  • EXPOSE
  • CMD

Create .dockerignore

Create Docker Compose file

  • docker-compose.yml
  • docker-compose.dev.yml
  • docker-compose.prod.yml

Setup MongoDb Image Docker

  • Define Mongo Image
  • Define Mongo User Details
  • Add Named Volume
  • Add DB Connection In Express App

Add Following Into Express App

  • create Post Model
  • Create Post Controller
  • Create Post Routes
  • Add Routes Into Index
  • Add Middleware JSON
  • Create User Model
  • Create Auth Controller
  • Create User Routes
  • Add Routes Into Index
  • Add Bcryptjs For Store Encrypted Password
  • Encrypt Password In AuthController
  • Create Login In Auth Controller
  • Create Login Routes

Add Redis

  • Add Redis Image
  • Add Redis Dependencies Into Express App
  • Add Redis ENV
  • Add Redis Config
  • Add User Details Into Session
  • Add Middleware To Store Session Details
  • Add Middleware To Protect Unauthorized Access

Add Nginx

  • Add Nginx Image
  • Create default conf file
  • Add Nginx Configurations
  • Port Setup For Nginx


Personal Reference Note

  • Dockerfile:
  • Docker Ignore:
  • Docker Compose:
  • Volume:
  • Named Volumes:
  • Anonymous Volumes:
  • Read Only Volumes:
  • Node Run Command:
  • ENV Variables:
  • Switching Dev And Prod Env:
  • Args Docker Command:
  • DB Access In Container:
  • Getting IP From Container:
  • Depends On:
  • Start Order, Only Build Single Container:
  • Scale Up Using nginx & Load balancing:
  • Production Env Setup:
  • Push Github:
  • Pull Into Prod Env:
  • Prod Running Cycle:
  • Docker Hub:
  • Docker Swarm:
  • Watch Tower:

Commands And Tag Description

  • FROM:
  • WORKDIR:
  • COPY:
  • RUN(With Condition):
  • COPY(Two Steps):
  • EXPOSE:
  • CMD(Prod,Dev):
  • volume:
  • Tag(-V):
  • Tag(--no-deps):
  • Tag(--Force-recreate):
  • Tag(--Build):
  • Docker image ls:
  • Docker image rm:
  • Docker Build -t:
  • Tag(-d):
  • Tag(-f):
  • Volume prune:


Issues You Might Face

  • Nodemon Not Working In Docker Container, Then Change Run Command (--legacy-watch index.js)
  • Mongo Connection Issue.
  • Mongo Authentication Failed, Then Run
    (use admin; db.grantRolesToUser('admin', [{ role: 'root', db: 'admin' }]))
    • *admin = Your Mongo DB Username

node-docker-demo's People

Contributors

samgohel avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.