How to Containerize a MERN Application with Docker-Compose
Introduction
It is cool building a web application in your local environment, a computer until it is time to share your work with others and it doesn't run elsewhere apart from your computer. At times, it could even be versioning errors with the dependencies.
This is where containers come in.
Docker is an open-source tool that helps developers easily build, and deploy their applications as containers.
Containers contain everything an application needs to run including the source code, and dependencies.
-- Benefits of containers
In this tutorial, you will setup a development environment for a full-stack MERN app using Docker. You will create multi containers with Docker-compose.
At the end of this tutorial, you will have a working application running on Docker containers.
Prerequisites
To complete this tutorial, you will need:
- A computer (obviouly ๐)
- Docker installed on your local coputer
- A code editor like VScode
Step 1 - Clone the project
Clone the project repository and set it up on your local computer.
git clone ...
Navigate to the project directory
cd ...
Step 2 - Install Depenencies
Navigate to the backend folder and install the project dependencies.
cd backend
npm install
Navigate to the frontend folder and install the project dependencies
cd backend
npm install