NutriPlan is a Node.js application designed to generate daily meal plans based on a target calorie intake. The project leverages modern CI/CD practices, using Jenkins for continuous integration and deployment, Docker for containerization, and GitHub for version control. The system is triggered automatically using GitHub webhooks, ensuring that the latest code is always tested and deployed efficiently.
The application is deployed on an EC2 Free Tier instance and can be accessed at http://52.14.156.105:8000/.
- Node.js: Backend application built with Express.js.
- Docker: Containerization of the application for consistent deployment across environments.
- Jenkins: Automated CI/CD pipeline that builds, tests, and deploys the application.
- GitHub: Source code management and version control.
- Webhooks: Automated triggering of Jenkins builds on code changes in the GitHub repository.
- EC2 Deployment: Application is deployed on an EC2 Free Tier instance for live access.
To run this project locally or contribute to its development, you need to have the following installed:
- Node.js: Ensure you have Node.js installed (v12.x or later).
- Docker: Install Docker on your system.
- Jenkins: Set up a Jenkins instance with the necessary plugins for GitHub integration and Docker support.
.
├── Dockerfile # Docker configuration file
├── app.js # Main Node.js application file
├── package.json # Node.js project configuration
├── public/ # Static files (CSS, images, etc.)
├── views/ # EJS template files for rendering HTML
├── README.md # Project documentation
└── .gitignore # Git ignore file
Clone the repository to your local machine using the following command:
git clone https://github.com/direwolfsb/NutriPlan-Nodejs-Jenkins.git
cd NutriPlan-Nodejs-Jenkins
To build the Docker image and run the application in a container:
-
Build the Docker image:
docker build -t nutri-plan .
-
Run the Docker container:
docker run -d --name nutri-plan -p 3000:3000 nutri-plan
Access the application by navigating to http://localhost:3000 in your web browser.
This project uses Jenkins for continuous integration and deployment. Jenkins is configured to automatically build and deploy the application when changes are pushed to the GitHub repository.
- Install Jenkins: Ensure Jenkins is installed and running.
- Configure GitHub Webhook: Set up a webhook in the GitHub repository to notify Jenkins of new commits.
- Create a Jenkins job or pipeline that pulls the latest code from GitHub.
- The job should build the Docker image and run tests.
- On successful builds, the Docker container should be deployed automatically.
Ensure Jenkins has the appropriate credentials to access your GitHub repository and Docker daemon.
Below is an example of a Jenkins Pipeline script that builds, tests, and deploys the application:
pipeline {
agent any
stages {
stage('Clone Repository') {
steps {
git url: 'https://github.com/direwolfsb/NutriPlan-Nodejs-Jenkins.git', credentialsId: 'github-jenkins'
}
}
stage('Build Docker Image') {
steps {
script {
dockerImage = docker.build("nutri-plan:${env.BUILD_ID}")
}
}
}
stage('Run Tests') {
steps {
script {
dockerImage.inside {
sh 'npm test'
}
}
}
}
stage('Deploy') {
steps {
script {
dockerImage.run("-d -p 3000:3000 --name nutri-plan")
}
}
}
}
}
GitHub webhooks are configured to trigger the Jenkins pipeline automatically when code is pushed to the repository. This ensures that the latest changes are always built, tested, and deployed without manual intervention.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Whether it’s reporting a bug, suggesting an improvement, or submitting a fix, please create a pull request or raise an issue in the repository.
For any questions, issues, or support, please contact Suyog Bam at [email protected].
Thank you for using NutriPlan! We hope this application helps you achieve your health and nutritional goals.
You can copy and paste this updated README.md content into your GitHub repository. This version includes the deployment information, providing users with a direct link to access your live application on the EC2 instance.