Student | Freelance Web Developer | Open Source Developer

About meResume

Setting up Yaydoc on Heroku

Yaydoc takes as its input the information about a user’s repository containing the documentation in Markup files and generates a static website from it. The website also includes search functionality within the documentation. It supports various built-in and custom Sphinx themes.

Since the Web User Interface is now prepared with some solid features, it was time to deploy. We chose Heroku for this because of the ease with which we can build and scale the application at free of cost.

Yaydoc consists of two components; A Web User Interface and the Generation and Deployment Scripts. The Web UI being developed with NodeJs and the scripts involving Python modules, require us to include the following buildpacks

We need to set certain Environment Variables in Heroku for proper functioning of the Yaydoc. These include

  • GITHUB_CALLBACK_URL – URL where Github must return to after successful authentication
  • GITHUB_CLIENT_ID – Unique Client-Id generated by Github OAuth Application
  • GITHUB_CLIENT_SECRET – Unique Client-Secret generated by Github OAuth Application
  • HEORKU_CALLBACK_URL – URL where Heroku must return to after successful authentication
  • HEROKU_CLIENT_ID – Unique Client-Id generated by Heroku OAuth Application
  • HEROKU_CLIENT_SECRET – Unique Client-Secret generated by Heroku OAuth Application
  • ENCRYPTION_KEY – Required to encrypt Personal Access Token of the user
  • DEPLOYMENT – True, since the application is deployed to Heroku
  • PYPANDOC_PANDOC – Location of Pandoc binaries
  • SECRET – A very secret token
  • MONGODB_URI - URL to MongoDB database (mlab server)

Steps for Manual Deployment

Even though we offer the One-click Heroku deployment, performing a manual deployment is also quite simple. There is a need to define certain Buildpacks and Environment Variables, after which the app can be successfully deployed.

Install Heroku on your local machine

  • If you have a linux based Operating Systems, type the following command in the terminal

    wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
    

Note:- Details for other Operating Systems can be found at https://devcenter.heroku.com/articles/heroku-cli

Login to Heroku Server (Create an account if it doesn’t exist)

  • Type in the following command in your server, enter credentials and login

    heroku login
    

Deploy Yaydoc to Heroku

  • Clone the original yaydoc repository or your own fork and move to the directory of the cloned repository

    git clone https://github.com/<username>/yaydoc.git
    cd yaydoc/
    
  • Create a Heroku application using the following command

    heroku create <your-app-name>
    
  • Add buildpacks to the application using the following commands

    heroku buildpacks:set heroku/nodejs
    heroku buildpacks:add --index 2 heroku/python
    heroku buildpacks:add --index 3 https://github.com/imujjwal96/heroku-buildpack-pandoc.git
    heroku buildpacks:add --index 4 https://github.com/heroku/heroku-buildpack-cli
    heroku buildpacks:add --index 5 https://github.com/heroku/heroku-buildpack-jvm-common
    
  • Set the required Environment Variables using the following commands

    heroku config:set DEPLOYMENT=true
    heroku config:set ENCRYPTION_KEY=AVERYSECRETTOKENOFTHIRTYTWOCHARACTERS
    heroku config:set GITHUB_CALLBACK_URL=https://<your-app-name>.herokuapp.com/auth/github/callback
    heroku config:set GITHUB_CLIENT_ID=<github-generated-client-id>
    heroku config:set GITHUB_CLIENT_SECRET=<github-generated-client-secret>
    heroku config:set HEROKU_CALLBACK_URL=https://<your-app-name>.herokuapp.com/auth/heroku/callback
    heroku config:set HEROKU_CLIENT_ID=<heroku-generated-client-id>
    heroku config:set HEROKU_CLIENT_SECRET=<heroku-generated-client-id>
    heroku config:set HOSTNAME=<your-app-name>.herokuapp.com
    heroku config:set MONGODB_URI=mongodb://<username>:<password>@ds151662.mlab.com:51662/<mlab-db-name>
    heroku config:set PYPANDOC_PANDOC=~/vendor/pandoc/bin/pandoc
    heroku config:set SECRET=<a-very-secret-token>
    heroku config:set SENDGRID_PASSWORD=<sengrid-password>
    heroku config:set SENDGRID_USERNAME=<sendgrid-username>
    
  • Now deploy your code

    git push heroku master
    
  • Visit the app at the URL generated by its app name

    heroku open
    

    Your app should be available at : https://your-app-name.herokuapp.com/

Original Post:- http://blog.fossasia.org/setting-up-yaydoc-on-heroku/