Navigation

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags
    • Users
    • Groups
    1. Home
    2. meshmellow
    3. Best
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 5
    • Best 2
    • Groups 2

    Best posts made by meshmellow

    • Getting NodeBB and plugins setup with Heroku (and MongoDB)

      Trying to setup NodeBB with Heroku

      Originally I had a lot of problems trying to get NodeBB as a Heroku app running, so I thought I would make a guide on how I did it in case anyone else runs into the same issues I faced.
      Full disclosure: Running Windows 8.1 Pro and I am inexperienced with Heroku, NodeJS, git and all this. But this is what I had to do to get my setup working, I hope it can help someone.

      Heroku — NodeBB 1.x documentation

      I started out by following this step by step, but I ran into some problems

      Here's what I did differently to get my NodeBB working

      I am assuming you already have a Heroku account setup in this tutorial.

      Step 1) Open up command prompt and navigate to the root folder
      cd\
      Step 2) Clone the NodeBB repository to the path where you want your NodeBB
      git clone -b v1.x.x https://github.com/NodeBB/NodeBB.git /path/to/where/you/want/nodeBB/
      For example - git clone -b v1.x.x https://github.com/NodeBB/NodeBB.git /nodeBB-local/
      Step 3) Go to the folder where you put NodeBB
      cd /path/to/your/nodeBB/
      For example - cd /nodeBB-local/
      Step 4) Install dependencies locally
      npm install --production
      Step 5) Create your Heroku App
      heroku create
      Remember the URL for your App (ie. https://appname.herokuapp.com/)

      Step 6) If you have a mongoDB already you can use that information instead
      But if you don't have one and still want to try out NodeBB with Heroku (and if you MUST use Heroku with MongoDB, I'd say it seems there are easier alternatives) you can setup a Sandbox MongoLab DB for now:
      Step 6.a) In command prompt while logged into Heroku with the right app
      heroku addons:create mongolab
      Step 6.b) After it has been created, check your config variables:
      heroku config
      If your MongoLab addon got added correctly it will show you your MongoDB information
      MONGODB_URI => mongodb://mongoDB_username:mongoDB_password@mongoDB_host:mongoDB_port/mongoDB_db
      Since this is pulled from your Heroku config variables there might be an easier way of getting your DB information from there into NodeBB, and it would make it a lot easier if your mongoDB host or information changes for whatever reason.

      Step 7) If everything has gone through without error, it's time to setup nodeBB
      node app --setup
      This is where you will tell NodeBB what Heroku App URL and database to use
      URL: https://appname.herokuapp.com/
      HOST IP / Address: mongoDB_host
      Port: mongoDB_port
      MongoDB Username: mongoDB_username
      Password: mongoDB_password
      Database to use: mongoDB_db

      Step 8.) Create the Procfile for Heroku
      echo web: node app.js > Procfile
      The documentation tells you to type echo "web: node loader.js --no daemon", but this didn't work for me.
      Repeatedly crashed on trying to start up, and so this workaround allowed me to start it and run it fine.
      However, it prevents the use of the Restart app functionality in the Admin API! (Reload still seems to work))
      Having to restart the Heroku app manually every time you want to install a plugin will also cause some issues as covered under the Plugins section.

      Step 9) Commit the Procfile, config.json and package.json
      git add -f Procfile config.json package.json && git commit -am "adding Procfile and configs for Heroku"
      Step 10) Push the v1.x.x branch to heroku as master
      git push -u heroku v1.x.x:master
      Step 11) Scale the web dyno up
      heroku ps:scale web=1
      Step 12 a.) Check to see if the app is running!
      heroku open
      Step 12 b.) Check your logs if not
      heroku logs

      Installing Plugins


      Now to install plugins on a NodeBB running on Heroku seems to be a bit different since you can't do it through their Admin API.
      Your plugin will gone on restart because Heroku doesn't save your generated files permanently!
      So instead you will have to install a plugin as a dependency so it gets included with the build, for this example I will use the Gravatar plugin, because as you might have guessed, Heroku wont save your avatars that are uploaded either. (NodeBB will save the URL reference to database, resulting in broken images)

      Step 1) Install the nodebb-plugin-gravatar as a dependency and save it to the package.json
      npm install nodebb-plugin-gravatar --save
      Step 2) Commit the package.json to the next push
      git add -f package.json && git commit -am "updating package.json"
      Step 3) If you've installed all your desired plugins then you can push it to Heroku again and then activate your plugins through the NodeBB Admin API
      git push heroku v1.x.x:master

      You will have to locally add the images to the appropriate folders such as the site logo for example (upload/system/site-logo.png) because if you upload them through the Admin API they will also disappear due to how Heroku stores files

      Image Hosting APIs alternatives might be worth looking into

      Image Hosting APIs — NodeBB 1.x documentation
      posted in Tutorials
      meshmellow
      meshmellow
    • RE: Editing post flagged as spam by Akismet

      @wktang It's a good question, I had the same problem trying to post a tutorial the other week. I solved it by editing in each piece bit by bit. Dirty work-around, but hey, what can you do when it doesn't give you clear outlines.

      posted in NodeBB Development
      meshmellow
      meshmellow