This project is a MERN (MongoDB, Express.js, React, and Node.js) Application. It's a simple employee management app that let's you add and edit records of your employee.
The main purpose of this repo is to serve as an example of how one can deploy a modern web application using Azure Cloud Services in two ways.
- CI/CD Workflows to deploy to Azure Static Web App and Azure Web App
- CI/CD Workflows to deploy to Azure Container Apps
-
Notion Guide (Without Docker - Azure Static Web App and Azure Web App): Click Here. Watch Full Tutorial 👇
-
Notion Guide (With Docker - Azure Container Apps): Click Here (Checkout Part 3 of this guide). Watch Full Tutorial 👇
- MongoDB: A NoSQL database for storing application data.
- Express.js: A web application framework for Node.js.
- React: A JavaScript library for building user interfaces.
- Node.js: A JavaScript runtime for server-side programming.
- Azure Web App: PaaS by Azure to deploy Express Application
- Azure Static App: PaaS by Azure to deploy Static Assets (React App)
- MongoDB: NoSQL Database deployed on MongoDB Atlas
- Azure Container Apps: PaaS by Azure to deploy containers
Before you begin, ensure you have met the following requirements:
- Node.js: Install Node.js from nodejs.org.
- MongoDB: Create MongoDB Atlas Database from mongodb.com.
- Docker (optional): Install Docker from docker.com.
-
Clone the repository:
git clone https://github.com/sagar-uprety/MERN-App-Deployment-Automation.git cd mern-stack-example
-
Install server dependencies:
cd app/server npm install
-
Setup config.env in app/server direcotry
ATLAS_URI=<your-mongodb-ATLAS-connection-string> PORT=5050
-
Install client dependencies:
cd app/client npm install
-
Setup .env file in app/client directory
VITE_API_URL=http://localhost:5050
-
Run the server (from app/server):
npm run dev # or (Nodemon required) nodemon server.js # or npm start # Your backend should be running at localhost:5050
-
Run the client (from app/client):
# Vite is used during development environment npm run dev
-
Access the client application: Open your browser and navigate to http://localhost:5173.
The project structure is as follows:
mern-stack-example/
├── .github/workflows (GitHub Actions Workflow File for CI/CD)
├── app/
│ ├── server/ # Backend (Node.js + Express)
│ └── client/ # Frontend (React.js)
├── package.json # Client dependencies
├── .gitignore # Files to be ignored by Git
└── README.md # Project documentation
server
: Contains the server-side code.client
: Contains the client-side code.
-
Create a .env file (root folder) and add:
VITE_API_URL=http://localhost:5050
-
Add the following in docker.env (root folder)
ATLAS_URI=<your-mongodb-ATLAS-connection-string> PORT=5050
-
Build the Docker images:
docker-compose build
-
Run the Docker containers:
docker-compose up
-
Access the application: Open your browser and navigate to http://localhost:80 or http://localhost.
Contributions are always welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.