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
- Navigate to the AWS Identity and Access Management page
- From the Users tab, click Create New Users
- Enter the name for your user (e.g., kegbot), be sure Generate an access key for
each user is selected before clicking Create. - 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. - From the user details page make note of the User ARN.
Create S3 Bucket
- Navigate to the AWS S3 page
- Click Create Bucket
- Select a name and region and click Create. Note: name must be unique
- In the properties panel on the right select, Add bucket policy
- In the dialog box select AWS Policy Generator
- Change policy type to S3 Bucket Policy
- We need to create 2 statements, a public policy and an admin policy
- Public statement
* Effect - `Allow`
* Principal - `*`
* Action - `GetObject`
* ARN - `arn:aws:s3:::my-bucket-name/*,arn:aws:s3:::my-bucket-name`
- 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`
- After adding the 2 statements click Generate Policy.
- Paste this policy into the bucket policy editor and click Save.
- Navigate back to the IAM Users page.
- Select the user you created above.
- Click Attach User Policy.
- 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
- Click Add Statement
- Click Next Step, add a meaningful name (e.g., S3FullAccessKegbot)
- 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
- git
-
heroku toolbelt
- OSX:
brew install heroku-toolbelt
- Ubuntu:
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
- OSX:
- SSH Key (https://devcenter.heroku.com/articles/keys)
Deployment
- Clone the project
git clone https://github.com/szechyjs/kegbot-heroku.git
- Change directory
cd kegbot-heroku
- Create Heroku app
heroku apps:create
orheroku apps:create my-kegbot-name
- Push to Heroku
git push heroku master
- Add New Relic for monitoring
heroku addons:add newrelic:stark
- Add MemCachier
heroku addons:add memcachier
- Add database
heroku addons:add heroku-postgresql:dev
- Add redis
heroku addons:add redistogo
- Add postmark
heroku addons:add postmark
- Set kegbot config path
heroku config:add KEGBOT_SETTINGS_DIR="/app/"
- Set a django secret key
heroku config:add SECRET_KEY='...'
(you can generate one here - http://www.miniwebtool.com/django-secret-key-generator/) - Set your outgoing email address
heroku config:add EMAIL_FROM_ADDRESS="[email protected]"
- 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"
- Initialize database
heroku run kegbot syncdb --all --noinput -v 0
heroku run kegbot migrate --all --fake --noinput -v 0
- Upload static files to S3 bucket
heroku run kegbot collectstatic
- 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.
- Get latest changes
git pull
- Push the changes to Heroku
git push heroku master
- Run the upgrade scripts
heroku run kegbot upgrade
Contributing
Please report issues or send a pull request on github