The best practice to set up cpanel with mongoDB on a cloud server!
irl last edited by
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!
- should i simply install and run the mongoDB on my centos 7?
- 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 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.
I don't know any other similar open source platform.
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 buildto generate the image
docker run -p 80:xyz. xyz* is the port of your application