Simplest way to deploy your Deno application with MongoDB database

Tutorial how to deploy a Deno app with MongoDB database with Qovery

Deno is a secure runtime for JavaScript and TypeScript based on the V8 engine and Rust programming language. It was created by Ryan Dahl, the same person who is the creator of good ol’ Node.js.

This article is not meant to teach you Deno, but it’s worth to mention its main cool features:

  • Secure by default, runs in a sandbox. No file, network, or environment access, unless explicitly enabled. You need to add flags to gain permissions.
  • TypeScript compiler baked in, works out of the box.
  • Has built-in utilities like a dependency inspector (deno info) and a code formatter (deno fmt).
  • Ships only a single executable file.
  • Decentralized packages. No more NPM packages / package.json. Packages are imported from URLs and are cached on the hard drive on load.
  • Extensive standard library.
  • ES Modules import syntax over require syntax.
  • Browser compatible API e.g. fetch.

Without further due, let's move on to next post section where we'll deploy a Deno application with MongoDB on scalable cloud platform.

Deployment

This tutorial show you how to deploy your Deno application with MongoDB database. Let's go!

Steps to deploy Deno with Qovery

  • Sign in to the Qovery web interface.

    Qovery Sign-up page

  • Deployment

    Deno sample application

    Get a copy of the sample source code of Deno sample project by forking it.

    To deploy your Deno application connected to a MongoDB, you can use our sample code and follow the configuration steps.

    In this example we are using MongoDB v3.6.

    1. Create a new project

      Migrate from Heroku

    2. Create a new environment

      Migrate from Heroku

    3. Create a new application

      To follow the guide, you can fork and use our repository

      Use the forked repository (and branch master) while creating the application in the repository field:

      Migrate from Heroku

    4. Select application port

      After the application is created:

      • Navigate application settings
      • Select Port
      • Add port 8080

      Port

    5. Use Dockerfile

      In the settings General section, set Build Mode to Dockerfile and set Dockerfile path as "Dockerfile"

    6. Deploy a MongoDB database

      In your envioronment view, click on Add and Database buttons:

      Template DB Deno

      In the popup window while adding a database, choose your name, select MongoDB and 3.6 version.

      Template DB

    7. Connect Deno to MongoDB

      Credentials of your MongoDB database are available via Environment Variables and Secrets. Qovery injects environment vars at the runtime.

      You can learn more about environment variables and secrets here.

      To list all the environment variables available to your Deno application, you can open Environment Variables and Secret tabs in your application window:

      Secret

    8. Deploy the app on Qovery

      All you have to do now is to navigate to your application and click Deploy button

      Deploy App

      That's it. Watch the status and wait till the app is deployed.

    Congratulations! Your environment with Deno application and MongoDB database should be in progress.

    Trigger a new deployment

    Now, you can play with the sample Deno application and commit & push your changes. Qovery detects your actions and triggers new builds and application deployments. Any change you make will be reflected in your deployed application automatically.

    Conclusion

    Congratulations! Now, you know how to deploy your Deno app with MongoDB in just a few steps.

    Do you have any feedback about this tutorial? Let us know what you think on Discord, and join our wonderful dev community of +5500 devs.