Skip to content

A boilerplate node/express application with Docker integration. Read the supporting article for this project over at Medium ๐Ÿ‘‡

License

Notifications You must be signed in to change notification settings

Aakash1103Jha/node-express-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

20 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

GitHub repo size GitHub GitHub issues GitHub top language GitHub commit activity

Node Express Docker

A boilerplate node/express application with Docker integration.

Stack

Typescript NodeJS Express Express MongoDB

Features

  • Typescript
  • Docker
  • Logging (with Winston)
  • Sequelize for SQL DB (currently using PostgreSQL in this project)

Getting Started

  • Clone the project or create a new project using this as a template.

  • Install dependencies using npm i

  • Add a .env file, surely will be required at some point.

  • If you would like to use MongoDB Atlas, add MONGO_URI in the .env file, with your DB connection URI.

  • If you proceed to use sequelize, then add the following in the .env file

    SEQUELIZE_DIALECT=/* one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' */
    SEQUELIZE_PORT=your_db_port
    SEQUELIZE_DATABASE_NAME=your_db_name
    SEQUELIZE_DATABASE_USERNAME=your_username
    SEQUELIZE_DATABASE_PASSWORD=your_password
    
  • All log files are generated in ./src/logs directory

Building an Image and Starting a Container

  • Run make up-dev to run the dev environment, or make up-prod for the production environment.

  • If you'd like to change container-port mapping, make changes in docker-compose.yml or docker-compose.prod.yml file, in the PORTS property -

    PORTS: "<your_new_port>:4000"
  • In case you decide to not use docker-compose, make the same port-mapping change in the run-image command in the Makefile.

  • Visit localhost:4000/welcome to check if everything is working.

  • Feel free to make any other changes, according to your project needs.

Learning Outcomes

  • better understanding about simple and complex concepts of Docker, alongside NodeJS.
  • setup a node/express application using Docker.
  • create and optimize workflows using Dockerfile, docker-compose and Makefile.
  • create and support multiple environments - development | production.
  • create separate loggers for development and production environment using Winston

Challenges / Blockers / Issues

  • docker commands
  • container port mapping

About

A boilerplate node/express application with Docker integration. Read the supporting article for this project over at Medium ๐Ÿ‘‡

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published