-
Clone the boilerplate template and install dev dependencies:
$ git clone git@github.com:marquee/runtime.git <project_name>
$ cd <project_name>
(If it’s a pre-existing project, clone from the project repo instead.)
-
Install the various requirements:
$ mkvirtualenv <project_name>
$ pip install -r requirements.txt
$ npm install
-
Re-initialize the repo and copy the .env templates:
$ cake init
(If this is a pre-existing project, use
init:env
instead.) -
Add additional remotes (if necessary)
$ git add remote origin git@git.droptype.com:<project_name>.git
$ git add remote heroku git@heroku.com:<project_name>.git
-
Fill out the environment variables:
In
.env
:CONTENT_API_TOKEN
- A read-only ApplicationToken issued by Marquee.PUBLICATION_NAME
- Arbitrary project namePUBLICATION_SHORT_NAME
- The short name, used to prefix the asset uploads
In
.env-development
:AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
(They are in separate files to keep credentials that have write access segregated. The
.env
file MUST NOT ever contain API tokens or Access Keys or whatever that have write privileges.)
First, make sure you are in the virtualenv: $ workon <project_name>
To run the project in debug mode, with the auto reloader, use
$ python run.py debug
.
To run the project as if it is on Heroku, use $ foreman start
. The project
also supports caching using redis. To use this locally, start redis and set
the REDIS_URL
in .env
.
(Assuming Heroku)
If this is the first time the app is being deployed, you need to set
certain environment variables using $ heroku config:set
They can be set (almost) all at once:
$ heroku config:set CACHE_SOFT_EXPIRY=10 CONTENT_API_TOKEN=<read_only_token> CONTENT_API_ROOT=marquee.by/content/ DEBUG=False ENVIRONMENT=production PUBLICATION_NAME="<publication name>" SECRET_KEY=<secret_key> PUBLICATION_SHORT_NAME=<short_name>
To deploy the code, just $ git push heroku master
. You’ll also want
to run $ cake deploy:static
if you made changes to the static assets.
Static assets require CoffeeScript and Compass, as usual. The build process is
managed by cake
. The source files go into static_source/
and come out in
static/
.
-
flush:static
- clear thestatic/
directory -
build
- flush static and rebuild all static filesbuild:scripts
- compile just the scriptsbuild:styles
- compile just the stylesbuild:other
- copy non-coffee/-sass files
-
watch
- flush static and start the CoffeeScript and Compass watchersNote: there is nothing running that updates images when they change, so you’ll have to run
$ cake build:other
to update those. -
deploy:static
- build and upload the static files to S3If you’ve set up the project as a Heroku app, this command will also update the
STATIC_URL
env variable of the app and restart the server, using theheroku config:set
command.
In development, static assets for offsite publications are served locally by
the Flask app. In production, the assets are served at http://cdn.mrqe.co
,
via CloudFront. The assets are stored in the cdn.mrqe.co
S3 bucket, with the
keys prefixed by <short_name>/<hash>
, where <hash>
is the first 18
characters of a SHA-1
hash of the asset contents.
To refer to a static asset in the templates, use
{{ static_url('filename.jpg') }}
. This will use the appropriate STATIC_URL
.