{"id":18574252,"url":"https://github.com/sabaurgup/simple-nodejs-devops-workflow","last_synced_at":"2025-05-15T23:34:24.121Z","repository":{"id":243569607,"uuid":"812780644","full_name":"SabaUrgup/simple-nodejs-devops-workflow","owner":"SabaUrgup","description":"DevOps Workflow Implementation for Basic Node.js App","archived":false,"fork":false,"pushed_at":"2024-06-21T13:26:49.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T14:49:14.185Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SabaUrgup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-09T21:20:36.000Z","updated_at":"2024-06-21T13:26:52.000Z","dependencies_parsed_at":"2024-12-26T14:44:41.081Z","dependency_job_id":"5d847c45-0995-4194-a4b0-7e55e6e326b3","html_url":"https://github.com/SabaUrgup/simple-nodejs-devops-workflow","commit_stats":null,"previous_names":["sabaurgup/simple-nodejs-devops-workflow"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SabaUrgup%2Fsimple-nodejs-devops-workflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SabaUrgup%2Fsimple-nodejs-devops-workflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SabaUrgup%2Fsimple-nodejs-devops-workflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SabaUrgup%2Fsimple-nodejs-devops-workflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SabaUrgup","download_url":"https://codeload.github.com/SabaUrgup/simple-nodejs-devops-workflow/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442429,"owners_count":22071864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T23:14:29.291Z","updated_at":"2025-05-15T23:34:24.028Z","avatar_url":"https://github.com/SabaUrgup.png","language":"JavaScript","readme":"# Simple Node.js DevOps Workflow\n\nThis repository contains a simple Node.js application with a complete DevOps workflow, including version control, containerization, orchestration, CI/CD pipeline, and monitoring.\n\n## Table of Contents\n\n1. [Steps](#steps)\n   - [Setup and Version Control](#setup-and-version-control)\n   - [Dockerization](#dockerization)\n   - [Kubernetes Deployment](#kubernetes-deployment)\n   - [CI/CD Pipeline](#cicd-pipeline)\n   - [Monitoring](#monitoring)\n2. [Getting Started](#getting-started)\n3. [License](#license)\n\n## Steps\n\n### Setup and Version Control\n\n1. **Initialize a Git repository and commit your code**:\n    ```sh\n    git init\n    git add .\n    git commit -m \"Initial commit: Basic Node.js application setup\"\n    ```\n2. **Push to a remote repository (GitHub/GitLab)**:\n    ```sh\n    git remote add origin https://github.com/SabaUrgup/simple-nodejs-devops-workflow.git\n    git push -u origin master\n    ```\n\n### Dockerization\n\n1. **Create a Dockerfile**:\n    ```Dockerfile\n    FROM node:20\n    WORKDIR /usr/src/app\n    COPY package*.json ./\n    RUN npm install\n    COPY . .\n    CMD [\"node\", \"app.js\"]\n    ```\n    - This Dockerfile sets up a Node.js environment, installs dependencies, copies the application code, and starts the application.\n\n2. **Build and run the Docker container**:\n    ```sh\n    docker build -t saba-express-app .\n    docker run -p 3000:3000 saba-express-app\n    ```\n    - This builds a Docker image named `saba-express-app` and runs a container exposing it on port 3000.\n\n### Kubernetes Deployment\n\n1. **Set up Minikube**:\n    ```sh\n    minikube start\n    ```\n    - Minikube sets up a local Kubernetes cluster for development and testing.\n\n2. **Create Kubernetes manifests** (`deployment.yaml` and `service.yaml`):\n\n    **deployment.yaml**\n    ```yaml\n    apiVersion: apps/v1\n    kind: Deployment\n    metadata:\n      name: saba-express-app\n    spec:\n      replicas: 3\n      selector:\n        matchLabels:\n          app: saba-express-app\n      template:\n        metadata:\n          labels:\n            app: saba-express-app\n        spec:\n          containers:\n          - name: saba-express-app\n            image: saba-express-app:latest\n            ports:\n            - containerPort: 3000\n    ```\n\n    **service.yaml**\n    ```yaml\n    apiVersion: v1\n    kind: Service\n    metadata:\n      name: saba-express-app-service\n    spec:\n      selector:\n        app: saba-express-app\n      ports:\n        - protocol: TCP\n          port: 80\n          targetPort: 3000\n      type: LoadBalancer\n    ```\n\n3. **Deploy to Minikube**:\n    ```sh\n    kubectl apply -f deployment.yaml\n    kubectl apply -f service.yaml\n    ```\n    - These commands apply the deployment and service configurations to the Kubernetes cluster, deploying the application and exposing it via a load balancer.\n\n### CI/CD Pipeline\n\n1. **Set up Jenkins**:\n    - Install Jenkins on your local machine or Minikube cluster:\n      ```sh\n      kubectl create namespace jenkins\n      helm repo add jenkins https://charts.jenkins.io\n      helm repo update\n      helm install jenkins jenkins/jenkins --namespace jenkins\n      ```\n\n2. **Create a Jenkinsfile**:\n    ```groovy\n    pipeline {\n        agent any\n    \n        environment {\n            DOCKER_REGISTRY = 'localhost:5000'\n            IMAGE_NAME = 'saba-express-app'\n            IMAGE_TAG = 'latest'\n        }\n    \n        stages {\n            stage('Build') {\n                steps {\n                    script {\n                        sh 'npm install'\n                    }\n                }\n            }\n    \n            stage('Docker Build') {\n                steps {\n                    script {\n                        sh \"docker build -t ${DOCKER_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG} .\"\n                    }\n                }\n            }\n    \n            stage('Docker Push') {\n                steps {\n                    script {\n                        sh \"docker push ${DOCKER_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}\"\n                    }\n                }\n            }\n    \n            stage('Publish') {\n                steps {\n                    script {\n                        sh 'kubectl apply -f deployment.yaml'\n                        sh 'kubectl apply -f service.yaml'\n                    }\n                }\n            }\n        }\n    \n        post {\n            success {\n                echo 'Pipeline completed successfully!'\n            }\n            failure {\n                echo 'Pipeline failed.'\n            }\n        }\n    }\n    ```\n    - This Jenkinsfile defines a pipeline with stages for building, testing, and deploying the application.\n\n3. **Push the Jenkinsfile to the repository**:\n    ```sh\n    git add Jenkinsfile\n    git commit -m \"Add Jenkins pipeline script for CI/CD automation\"\n    git push\n    ```\n\n### Monitoring\n\n1. **Set up Prometheus and Grafana** using Helm charts or Kubernetes manifests:\n    ```sh\n    kubectl create namespace monitoring\n    helm repo add prometheus-community https://prometheus-community.github.io/helm-charts\n    helm repo add grafana https://grafana.github.io/helm-charts\n    helm repo update\n    helm install prometheus prometheus-community/kube-prometheus-stack --namespace monitoring\n    helm install grafana grafana/grafana --namespace monitoring\n    ```\n\n2. **Configure Prometheus** to scrape metrics from your application.\n\n3. **Create a Grafana dashboard** to visualize the metrics.\n\n## Getting Started\n\nClone the repository and follow the steps above to set up and deploy the application.\n\n```sh\ngit clone https://github.com/SabaUrgup/simple-nodejs-devops-workflow.git\ncd simple-nodejs-devops-workflow\n```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabaurgup%2Fsimple-nodejs-devops-workflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsabaurgup%2Fsimple-nodejs-devops-workflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabaurgup%2Fsimple-nodejs-devops-workflow/lists"}