HowTo: Install Kegbot Server on Heroku

Heroku is an easy to use cloud platform as a service that makes it very easy to deploy Kegbot to the cloud.

Requirements

  • A Heroku account - free for single dyno apps like this
  • An AWS account and S3 bucket - costs less than $1/month

AWS Configuration

If you don’t have experience with S3 and AWS this part may be a little difficult, I’m going to do my best to walk you through the process. If anyone knows of any good tutorials on this please let me know.

Create API Keys

  1. Navigate to the AWS Identity and Access Management page
  2. From the Users tab, click Create New Users
  3. Enter the name for your user (e.g., kegbot), be sure Generate an access key for
    each user is selected before clicking Create.
  4. On the next page be sure to copy down the generated access keys. Note: this is
    the only time you can see the keys, if you lose the keys they must be regenerated.
  5. From the user details page make note of the User ARN.

Create S3 Bucket

  1. Navigate to the AWS S3 page
  2. Click Create Bucket
  3. Select a name and region and click Create. Note: name must be unique
  4. In the properties panel on the right select, Add bucket policy
  5. In the dialog box select AWS Policy Generator
  6. Change policy type to S3 Bucket Policy
  7. We need to create 2 statements, a public policy and an admin policy
  8. Public statement
 * Effect - `Allow`
 * Principal - `*`
 * Action - `GetObject`
 * ARN - `arn:aws:s3:::my-bucket-name/*,arn:aws:s3:::my-bucket-name`
  1. Admin statement
 * Effect - `Allow`
 * Principal - The User ARN from above (e.g., arn:aws:iam::000000000000:user/kegtest)
 * Action - `All Actions ('*')`
 * ARN - `arn:aws:s3:::my-bucket-name/*,arn:aws:s3:::my-bucket-name`
  1. After adding the 2 statements click Generate Policy.
  2. Paste this policy into the bucket policy editor and click Save.
  3. Navigate back to the IAM Users page.
  4. Select the user you created above.
  5. Click Attach User Policy.
  6. Select Policy Generator.
  • Effect - Allow
  • AWS Service - Amazon S3
  • Actions - All Actions ('*')
  • ARN - arn:aws:s3:::my-bucket-name/*,arn:aws:s3:::my-bucket-name
  1. Click Add Statement
  2. Click Next Step, add a meaningful name (e.g., S3FullAccessKegbot)
  3. Click Apply Policy

Deployment Methods

Deploy to Heroku

The easiest way to deploy Kegbot to Heroku is through the ‘Deploy to Heroku’ button. Navigate to the kegbot-heroku repository on github. At the top of the README you’ll find the Deploy to Heroku button. Clicking this button will take you to Kegbot new app deployment wizard on Heroku. Fill in the following fields and click Deploy.

  • App Name - this will be the subdomain of your app: my-kegbot.herokuapp.com
  • AWS_SECRET_ID - The ID generated in the IAM step
  • AWS_SECRET_ACCESS_KEY - The access key generated in the IAM step
  • AWS_STORAGE_BUCKET - The name of your bucket
  • AWS_S3_CUSTOM_DOMAIN - The domain name of your bucket (my-bucket-name.s3.amazonaws.com)
  • EMAIL_FROM_ADDRESS - The email address you wish notifications to come from

Click ‘Deploy for Free’. It will take a couple of minutes to complete the deployment process. Once the deployment completes it will provide you with a link to your newly deployed Kegbot server. Follow this link to complete the setup.

Manually

If you have more familiarity with command line tools such as git this may be your preferred deployment method.

Requirements

Deployment

  1. Clone the project git clone https://github.com/szechyjs/kegbot-heroku.git
  2. Change directory cd kegbot-heroku
  3. Create Heroku app heroku apps:create or heroku apps:create my-kegbot-name
  4. Push to Heroku git push heroku master
  5. Add New Relic for monitoring heroku addons:add newrelic:stark
  6. Add MemCachier heroku addons:add memcachier
  7. Add database heroku addons:add heroku-postgresql:dev
  8. Add redis heroku addons:add redistogo
  9. Add postmark heroku addons:add postmark
  10. Set kegbot config path heroku config:add KEGBOT_SETTINGS_DIR="/app/"
  11. Set a django secret key heroku config:add SECRET_KEY='...'
    (you can generate one here - http://www.miniwebtool.com/django-secret-key-generator/)
  12. Set your outgoing email address heroku config:add EMAIL_FROM_ADDRESS="[email protected]"
  13. Set the following config variables for your S3 bucket.
  • heroku config:add AWS_ACCESS_KEY_ID="XXXXXXXXXXXXXXXXXXXX"
  • heroku config:add AWS_SECRET_ACCESS_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  • heroku config:add AWS_STORAGE_BUCKET_NAME="bbbbbbbb"
  • heroku config:add AWS_S3_CUSTOM_DOMAIN="bbbbbbbb.s3.amazonaws.com"
  1. Initialize database
  • heroku run kegbot syncdb --all --noinput -v 0
  • heroku run kegbot migrate --all --fake --noinput -v 0
  1. Upload static files to S3 bucket heroku run kegbot collectstatic
  2. Visit site heroku open and finish initial configuration

Configure Email

Once the site is deployed you must register your outgoing email address
with Postmark before emails will actually send. This can be done through the
Postmark configuration page, accessible from the addons section of your deployed
Heroku app.

Upgrading

If you deployed using the Deploy to Heroku I am still in the process of documenting the upgrade procedure. For those of you that manually deployed, do the following.

  1. Get latest changes git pull
  2. Push the changes to Heroku git push heroku master
  3. Run the upgrade scripts heroku run kegbot upgrade

Contributing

Please report issues or send a pull request on github