The best practice to set up cpanel with mongoDB on a cloud server!



  • I'm trying to set up my cloud server so i can run an app made with nodeJs and mongoDB, now for nodeJs my setup is to deploy it using cpanel on a cenos 7 os and since cpanel does not really support mongoDB i wonder what's the best practice to deploy mongoDB alongside of it!

    1. should i simply install and run the mongoDB on my centos 7?
    2. should i install docker alongside cpanel and run mongoDB inside a docker container? i prefer this choice since docker has an official mongoDB Image but what i'm concerned about whether it would be okay if my cpanel is not actually in a docker container itself?


  • At a minimum you need access to the shell. Without the shell, you will work as if you were 20 years ago or more. If you will host just one web application, at least you also need a public ip or domain preferable with https

    Also the usage of environment variables to avoid hardcoded values are required.

    The following strategies assume that you have shell access and a public ip or domain.

    let's not reinvent the wheel

    Dokku

    Dokku is an open-source platform-as-a-service (PaaS). If you're familiar with Heroku, you can consider Dokku a private Heroku that you manage.

    Basically, after the installation, you will have a private git url in which if you push some standard code, the app will be deployed.

    • https://blog.back4app.com/what-is-dokku/
    • https://vimeo.com/68631325
    • https://www.freecodecamp.org/news/how-to-build-your-on-heroku-with-dokku/

    I don't know any other similar open source platform.

    Buddy

    https://buddy.works/pricing

    In this platform you could automate some tasks. It is like a mini jenkins

    Minimal manual implementation

    • Create a github repository
    • Add a Dockerfile to your source code
    • Use environment variables instead hardcoded values of database connection in the source code
    • Install docker and git in the server
    • Start a mongodb using docker and volumes
    • After tests on your localhost, push to github
    • Enter to the cloud and clone the git repository
    • Execute the docker build to generate the image
    • Execute docker run -p 80:xyz. xyz* is the port of your application



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2