Skip to content

Commit

Permalink
Add Heroku support
Browse files Browse the repository at this point in the history
Move .bowerrc, bower.json, gulpfile.js, package.json
down to root level.
Update paths in .bowerrc, gulpfile.js, Makefile
Add a heroku-postbuild step to package.json which
installs devDependencies and runs the build.
Add step in bin/pre_compile which adds the
requirements_all_ds.txt to requirements.txt to ensure that
cffi is installed. Also removes pymssql as this is
not supported on Heroku.
Add content from rd_ui/.gitignore to .gitignore and
remove rd_ui/.gitignore.
Add section in setup.rst about Heroku deployments.
  • Loading branch information
adamlwgriffiths committed Jun 3, 2016
1 parent cfb852e commit c75054b
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "rd_ui/app/bower_components"
}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ dump.rdb

# Docker related
docker-compose.yml

node_modules
.tmp
.sass-cache
rd_ui/app/bower_components
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ BASE_VERSION=$(shell python ./manage.py version | cut -d + -f 1)
FILENAME=$(CIRCLE_ARTIFACTS)/$(NAME).$(VERSION).tar.gz

deps:
if [ -d "./rd_ui/app" ]; then cd rd_ui && npm install; fi
if [ -d "./rd_ui/app" ]; then cd rd_ui && npm run bower install; fi
if [ -d "./rd_ui/app" ]; then cd rd_ui && npm run build; fi
if [ -d "./rd_ui/app" ]; then npm install; fi
if [ -d "./rd_ui/app" ]; then npm run bower install; fi
if [ -d "./rd_ui/app" ]; then npm run build; fi

pack:
sed -ri "s/^__version__ = '([0-9.]*)'/__version__ = '$(FULL_VERSION)'/" redash/__init__.py
tar -zcv -f $(FILENAME) --exclude="optipng*" --exclude=".git*" --exclude="*.pyc" --exclude="*.pyo" --exclude="venv" --exclude="rd_ui/node_modules" --exclude="rd_ui/dist/bower_components" --exclude="rd_ui/app" *
tar -zcv -f $(FILENAME) --exclude="optipng*" --exclude=".git*" --exclude="*.pyc" --exclude="*.pyo" --exclude="venv" --exclude="node_modules" --exclude="rd_ui/dist/bower_components" --exclude="rd_ui/app" *

upload:
python bin/release_manager.py $(CIRCLE_SHA1) $(BASE_VERSION) $(FILENAME)

test:
nosetests --with-coverage --cover-package=redash tests/
#cd rd_ui && grunt test
#grunt test
2 changes: 2 additions & 0 deletions Procfile.heroku
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: ./manage.py runserver -p $PORT --host 0.0.0.0
worker: ./bin/run celery worker --app=redash.worker --beat -Q queries,celery,scheduled_queries
17 changes: 17 additions & 0 deletions bin/pre_compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# heroku post_compile script

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd $DIR/..

# heroku requires cffi to be in requirements.txt in order for libffi to be installed.
# https://github.com/heroku/heroku-buildpack-python/blob/master/bin/steps/cryptography
# to avoid making it a requirement for other build systems, we'll inject it now
# into the requirements.txt file
# remove pymssql, it doesn't compile on heroku
grep -v '^pymssql' requirements_all_ds.txt >> requirements.txt

# make the heroku Procfile the active one
cp Procfile.heroku Procfile

popd
File renamed without changes.
38 changes: 38 additions & 0 deletions docs/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,44 @@ Docker Compose
Now proceed to `"Setup" <#setup>`__.


Heroku
------

1. Install `Heroku CLI <https://toolbelt.heroku.com/>`_.

2. Create Heroku App::

$ heroku apps:create <app name>

2. Set application buildpacks::

$ heroku buildpacks:set heroku/python
$ heroku buildpacks:add --index 1 heroku/nodejs

3. Add Postgres addon::

$ heroku addons:create heroku-postgresql:hobby-dev

4. Add Redis addon::

$ heroku addons:create heroku-redis:hobby-dev

5. Set environment variables::

$ heroku config:set REDASH_DATABASE_URL=`heroku config:get DATABASE_URL`
$ heroku config:set REDASH_REDIS_URL=`heroku config:get REDIS_URL`
$ heroku config:set REDASH_COOKIE_SECRET='<create a secret token and put here>'

6. Push the repository to Heroku::

$ git push heroku master

7. Create database tables::

$ heroku run bash
$ python manage.py database create_tables


Other
-----

Expand Down
4 changes: 2 additions & 2 deletions rd_ui/gulpfile.js → gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ var wiredep = require('wiredep').stream;
var runSequence = require('run-sequence');

var yeoman = {
app: 'app',
dist: 'dist'
app: 'rd_ui/app',
dist: 'rd_ui/dist'
};

var paths = {
Expand Down
3 changes: 2 additions & 1 deletion rd_ui/package.json → package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"scripts": {
"test": "echo 'No tests.'",
"build": "gulp build",
"bower": "bower"
"bower": "bower",
"heroku-postbuild": "npm install --dev && npm run bower install && npm run build && npm prune --production"
},
"dependencies": {
}
Expand Down
3 changes: 0 additions & 3 deletions rd_ui/.bowerrc

This file was deleted.

4 changes: 0 additions & 4 deletions rd_ui/.gitignore

This file was deleted.

0 comments on commit c75054b

Please sign in to comment.