Skip to content

Cloud Hosting

Operation Privacy edited this page Jan 30, 2023 · 8 revisions

2. Instructions

Total installation time: < 60 mins

(setup is exactly the same as the live website)

a. Create a free database online

  • Go to www.MongoDB.com and create an account
  • Setup MFA
  • Create a free db
  • Get the connection string

(Tip: don't use any special characters in the password otherwise you'll have to convert each to it's ascii equivalent starting with a "%". Keep it long (20+).

  • Navigate to Databases > Collections > + Create Database

  • Call it anything like:

    Database Name: VoIPSuite
    Collection name: voip
  • Navigate to Network Access and input the IP 0.0.0.0/0 to allow access from anywhere. You are allowing the Hosted Application in Heroku to connect to the database. (This is not your IP. It's the IP of the server. Since we don't know it and it may be dynamic, we keep it to any.)

b. Create A GitHub Account

(for automatic updates and syncing the code with the cloud hosting option on Heroku, you can only connect your own repo or a forked repo)

  • Create an account on GitHub if you don't already have one. Secure it with MFA
  • Create a fork of this repo (so you use your own instance, but can manually update it on GitHub when the main branch has updates)

c. Create an account on Heroku

(Heroku has decided to eliminate their free tier option. Render is now the preferred option if you want a free option)

Heroku offers a free tier which also integrates seamlessly with a GitHub repo. Every time there's an update to the GitHub code, it auto pushes it to your hosted site.

Enter a credit card 💳 (use privacy.com and pause the card after you enter it in), you get a total of 1000 hours of uptime a month (one month has a max of 744 hours), otherwise you stay at 550 hours of uptime per month and the app is forced to sleep.

  • Create a username
  • Enable 2FA
  • Enter your credit card info
  • Connect your GitHub account (under Deploy)
  • (optional) Connect your domain (under Settings)

Environment Variables

  • If you're using Heroku, add the environment variables under the Settings tabs and the Reveal Config Vars button. You can find it at: https://dashboard.heroku.com/apps/[your-app-name]/settings
  • (If you're self hosting on a Linux machine, edit the .env file and update the variables to match your own credentials.)

NOTE: The variable name is case sensitive. (db is NOT equal to DB)

NOTE: All env variables must be set, you cannot omit any. leave them to the default values if you're not changing them.

Variable Description
DB The mongodb connection string you get from the previous steps. (localhost for self hosted)
ex. mongodb+srv://admin:password@xyz-cluster0.qxtle.mongodb.net/
BASE_URL For Heroku, enter the application URL you get OR the custom domain you enable.
ex. https://your-app-name.herokuapp.com/
For Render put in the URL you get like https://voipsuite123.onrender.com/
Don't forget to put the leading slash / at the end.
COOKIE_KEY Type any random string (around 20-50 random alphanumeric characters is good). This is used to encrypt your browser session. (click the random generate button)
PORT For Heroku or Render, leave it blank, it will auto assign a random port. For other hosting providers, set it to 8080 (the default) or any other port you wish to serve the app on
HTTPS default is false (for local testing without a certificate). Change it to true to force the page to redirect to https. You can also redirect it on your WAF or self hosted web or proxy server
NODE_OPTIONS --max_old_space_size=460 (This will set the max memory to be 460MB out of 512MB RAM which is allocated to the free tier and leave some memory for other processes. It will avoid out of memory errors and flush the memory periodically)

d. Deploy to Heroku

(Heroku has decided to eliminate their free tier option. Render is now the preferred option if you want a free option)

For Continuous Deployment:

  • You will need to Create A New App
  • Connect your GitHub account under Deploy
  • Search/Select your forked repository
  • Enable Automatic Deploys

OR

e. Deploy On Render

(With this service, you can skip the Heroku steps c & d altogether as it's an alternative. You can also skip step b by not creating your own GitHub account and just clone from the public repo to save time. But it's preferred to have your own copy of the code where you can control the updates and/or custom changes).

  1. Go to the website render.com and signup with an email address.

(Note: They disabled burner emails like SimpleLogin and @duck.com right after Heroku shut down their free tier 🙄. You can use custom domains or sign in with Github)

  1. Create a new Web Service

  2. Enter the url of your forked repo OR the public repo https://github.com/0perationPrivacy/VoIP

  3. Configure the options as follows:

    Name Pick a unique name (like voipsuit123) that will be part of the url, like voipsuit123.onrender.com
    Environment Node
    Build Command npm install
    Start Command node app.js
    Plans Free
    Advanced Configure the environment variables as previously described.
    Auto Deploy Yes
  4. The free service goes to sleep after 15 mins of inactivity and takes up to 30 seconds to wake up when you hit the url. Don't forget to configure UpTimeRobot to ping it every 5 seconds to keep it awake. A credit card 💳 is NOT required for the free tier and you get enough hours to run the app 24/7 (unlike Heroku).

  5. Add a custom domain. Add a CNAME entry in your dns. Create Redundancy with multiple services.

f. Update The App

Every time there's an update to the application, you will need to go to your forked repository and manually click on Fetch Upstream and Fetch & Merge. You Heroku or Deploy app will automatically sync with your fork as automatic deploys are set (a.k.a CI/CD). If there's no update, your fork will say "This branch is even with 0perationPrivacy:main"

If you put in the address of the public repository, you do not have to worry about updates. Your code will immediately update when the public repository has an update.