Try Devtron Enterprise for FREE!
Start Now
LogoLogo
WebsiteDevtron demoGithub RepoJoin Discord
v0.6
v0.6
  • Introduction
  • Getting Started
  • Install Devtron
    • Install Devtron with CI/CD
    • Install Devtron with CI/CD and GitOps (Argo CD)
    • Install Devtron without Integrations
    • Install Devtron on Minikube, Microk8s, K3s, Kind, Cloud VMs
    • Demo on Popular Cloud Providers
    • Backup for Disaster Recovery
    • Uninstall Devtron
    • FAQs
  • Devtron Kubernetes Client
  • Configurations
    • Installation Configurations
    • Override Configurations
    • Ingress Setup
  • Global Configurations
    • Host URL
    • GitOps
    • Projects
    • Clusters & Environments
    • Git Accounts
    • Container/OCI Registry
    • Chart Repositories
    • Custom Charts
    • Authorization
      • SSO Login Services
        • Google
        • GitHub
        • GitLab
        • Microsoft
        • LDAP
        • OIDC
        • OpenShift
        • Example - Okta SSO
      • User Permissions
      • Permission Groups
      • API Tokens
    • Notifications
    • External Links
    • Catalog Framework
    • Scoped Variables
    • Pull Image Digest
    • Tags Policy
    • Lock Deployment Configuration
    • Image Promotion Policy
    • Filter Condition
    • Build Infra
  • Devtron Upgrade
    • Update Devtron from Devtron UI
    • 0.5.x-0.6.x
    • 0.4.x-0.5.x
    • 0.4.x-0.4.x
    • 0.3.x-0.4.x
    • 0.3.x-0.3.x
    • 0.2.x-0.3.x
  • Usage
    • Applications
      • Create a New Application
      • Clone an Existing Application
      • Deploy a Sample Application
      • App Configuration
        • Git Repository
        • Build Configuration
        • Base Deployment Template
          • Deployment
          • Rollout Deployment
          • Job and Cronjob
          • StatefulSets
        • GitOps Configuration
        • Workflow Editor
          • CI Pipeline
            • Pre-Build/Post-Build Stages
            • Override Build Configuration
          • CI Pipeline (Legacy)
          • CD Pipeline
        • ConfigMaps
        • Secrets
          • External Secret Operator (ESO)
            • AWS Secrets Manager
            • Google Secrets Manager
            • HashiCorp Vault
        • Protect Configuration
        • Environment Overrides
        • Deleting Application
      • Build and Deploy
        • Triggering CI
        • Triggering CD
        • Rollback Deployment
      • App Details
        • Debugging Deployment And Monitoring
        • Using Ephemeral Containers
        • Application Metrics
      • Overview
    • Jobs
      • Create a new job
      • Configurations
      • Workflow Editor
      • Trigger Job
      • Overview
    • Application Groups
    • Resource Browser
    • Charts
      • Charts Overview
      • Deploy & Observe
      • Examples
        • Deploying Mysql Helm Chart
        • Deploying MongoDB Helm Chart
      • Chart Group
    • Security
      • Security Scans
      • Security Policies
    • Bulk Edit
    • Integrations
      • Build and Deploy (CI/CD)
      • GitOps (Argo CD)
      • Vulnerability Scanning (Clair)
      • Notifications
      • Monitoring (Grafana)
    • Pipeline Plugins
      • Codacy
      • Copy Container Image
      • Dependency track - Maven & Gradle
      • Dependency track - NodeJS
      • Dependency track - Python
      • K6 Load Testing
      • Semgrep
      • SonarQube
      • SonarQube v1.1.0
  • Resources
    • Glossary
    • Troubleshooting
    • Use Cases
      • Devtron Generic Helm Chart To Run CronJob Or One Time Job
      • Connect SpringBoot with Mysql Database
      • Connect Expressjs With Mongodb Database
      • Connect Django With Mysql Database
      • Pull Helm Charts from OCI Registry
    • Telemetry Overview
    • Devtron on Graviton
    • Release Notes
Powered by GitBook
On this page
  • Introduction
  • 1. Deploy mongoDb Helm Chart
  • 2. Fork the Git Repository
  • *Dockerfile
  • *db.js File
  • 3. Create Application on Devtron
  • *Git Repository
  • *Docker configuration
  • *Configure Deployment Template
  • *Set up the CI/CD Pipelines
  • *Trigger Pipelines
  • 4. Final Step

Was this helpful?

Export as PDF
  1. Resources
  2. Use Cases

Connect Expressjs With Mongodb Database

PreviousConnect SpringBoot with Mysql DatabaseNextConnect Django With Mysql Database

Last updated 10 months ago

Was this helpful?

Introduction

In this application, you will learn about how to create a Expressjs Application that connects to mongoDb.

Follow the below-mentioned steps, to deploy the application on Devtron using mongoDb Helm Chart.

1. Deploy mongoDb Helm Chart

To deploy mongoDb Helm Chart, you can refer to our documentation on

2. Fork the Git Repository

For this example, we are using the following , you can clone this repository and make following changes in the files.

*Dockerfile

This is the Dockerfile. This exposes our expressjs application to port number 8080

FROM node:7
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
CMD node server.js
EXPOSE 8080

*db.js File

This file will be used to connect to our database. This will include the service-name of the mongoDb Helm Chart, that you have deployed in Step1.

The syntax is as follows:

<service-name>:27017/<database-name>

This maps our service name to mongoDb's port number 27017.

module.exports = {
    DB: 'mondo-dev-mongodb-replicaset-client:27017/sale'
}

3. Create Application on Devtron

*Git Repository

In this example, we are using the url of the forked Git Repository.

*Docker configuration

Give, the path of the Dockerfile.

*Configure Deployment Template

Enable Ingress, and give the path on which you want to host the application.

*Set up the CI/CD Pipelines

Set up the CI/CD pipelines. You can set them to trigger automatically or manually.

*Trigger Pipelines

Trigger the CI Pipeline, build should be Successful, then trigger the CD Pipeline, deployment pipeline will be initiated, after some time the status should be Healthy

4. Final Step

Check the Expressjs app connected to mongodb database, running successfully by hitting your application url.

The syntax is: http://<hostname>/<path>/

path will be the one that you have given in Step 3 while configuring the Deployment Template.

The output of our application would be as follows:

You can see that we are getting the JSON response. We have successfully connected our expressjs application to the mongoDb database.

To learn how to create an application on Devtron, refer to our documentation on

Deploy mongoDb Helm Chart
GitHub Repo
Creating Application