Installation¶
Note
This project has been cancelled, and this information is historical.
Install Django Project¶
For detailed local installation instructions, including OS-specific instructions, see the Installation page on the wiki.
- Install system packages and libraries. The required packages are Python (2.7, 3.4, and/or 3.5), pip (latest), and virtualenv (latest). To match production and for a smooth installation of Python packages, install PostgreSQL (9.2 or later recommended) and Memcached (latest). virtualenvwrapper and autoenv will make your development life easier.
- Optionally, provision a PostgreSQL database, recommended to match
production. The default Django database settings will use a
SQLite database named
db.sqlite3
. - Optionally, run Redis or Memcached for improved read performance (production uses Redis for caching and for the Celery backend) The default settings will run without a cache or asynchronous tasks.
- Clone project locally.
- Create a virtualenv.
- Install dependencies with
pip install -r requirements/development.txt
. - Customize the configuration with environment variables.
See
wpcsite/settings.py
andenv.dist
for advice and available settings. - Initialize the database and a superuser account with
./manage.py migrate
. - Verify that tests pass with
./manage.py test
ormake test
. - Run it with
./manage.py runserver
or./manage.py runserver_plus
.
Install in Heroku¶
Heroku allows you to quickly deploy browsercompat. Heroku hosts the beta version of the service at https://browsercompat.herokuapp.com, using the add-ons:
- heroku-postgresql (hobby-basic tier, $9/month, required for size of dataset)
- memcachier (free dev tier)
- heroku-redis (free hobby-dev tier)
- Mozilla’s New Relic account (Heroku New Relic available, including free Wayne tier)
For more details of the beta server, see Beta Server on the github wiki.
To deploy with Heroku, you’ll need to signup for a free account and install the Heroku Toolbelt. Then you can:
- Clone project locally
heroku apps:create
git push heroku master
- See the current config with
heroku config
, and then customize with environment variables usingheroku config:set
(seewpcsite/settings.py
andenv.dist
) - Add superuser account (
heroku run ./manage.py createsuperuser
)
Configuring authentication¶
The project uses django-allauth as a framework for local and social authentication. The public service uses username and password for local authentication, and Firefox Accounts (FxA) for social authentication.
django-allauth supports multiple emails per user, with one primary email used for communication. Email addresses are validated by sending a confirmation link. For a public server, you’ll need to configure Django to send email, by configuring your mail server and setting environment variables. For local development, it is easiest to print emails to the console:
export EMAIL_BACKEND="django.core.mail.backends.console.EmailBackend"
django-allauth supports many social authentication providers. See the providers documentation for the current list and hints for configuration. Using an authentication provider is not required, especially for local development. Instead, use local authentication with a username and password.
If you need FxA integration, see the Firefox Accounts page on the wiki for install hints.
Load Data¶
There are several ways to get data into your API:
- Load data from documentation fixtures
- Load data from the github export
- Load data from another browsercompat server
Load from documentation fixtures¶
The integration tests and documentation use a subset of real compatibility data. This subset isn’t enough for a local compatibility server, but should be adequate for development work on the API software, and takes less than a minute to load:
- Run the API (
./manage.py runserver
) - Import the data (
tools/upload_data.py --data docs/v1/resources
)
Load from GitHub¶
The data on browsercompat.herokuapp.com is archived in the browsercompat-data github repo, and this is the fastest way to get complete data into your empty API:
- Clone the github repo (
git clone https://github.com/mdn/browsercompat-data.git
) - Run the API (
./manage.py runserver
) - Import the data (
tools/upload_data.py --data /path/to/browsercompat-data/data
)
Load from another browsercompat server¶
If you have read access to a browsercompat server that you’d like to clone, you can grab the data for your own server.
- Download the data (
tools/download_data.py --api https://browsercompat.example.com
) - Run the API (
./manage.py runserver
) - Import the data (
tools/upload_data.py
)