Article

Node.js TypeScript Docker MongoDB

November 09, 2023 - Rebaz Omar

Building a Node.js TypeScript Docker MongoDB Project

Introduction

Welcome to this blog post where we'll walk you through the process of building a Node.js TypeScript project integrated with MongoDB and Docker. This project aims to help you get started with modern web development using these powerful technologies.

We'll cover the essentials, prerequisites, and the step-by-step process to set up and run your project. So, let's dive in!

Prerequisites

Before we begin, you need to ensure that you have the following dependencies installed on your system:

Getting Started

Let's kick things off by setting up the project on your local machine. Follow these steps:

  1. Clone the repository:
  2. $ git clone --depth=1 https://github.com/rebazomar121/node-typescript-mongodb-starter your-project-name
  3. Navigate to the project directory:
  4. $ cd your-project-name
  5. Install project dependencies:
  6. $ npm install
  7. Configuration:
  8. $ cp .env.example .env
  9. Run the project In Development:
  10. $ npm run dev
  11. Run the project In Production:
  12. $ npm run build && npm start
  13. Running with Docker:
  14. $ docker build -t your-image-name .
  15. Run the container:
  16. $ docker run -p 8080:8080 -d your-image-name
  17. Running with Docker Compose:
  18. $ docker-compose up

    Note: You can change the configurations in the .env file.