The following describes how to set up an instance of the site on your computer for development.
This guide assumes you have already installed and set up the following:
These docs assume a Unix-like operating system, although the site should, in theory, run on Windows as well. All the example commands given below are intended to be run in a terminal.
Clone this repository or your fork:
git clone https://github.com/mozilla/normandy.git cd normandy
Create a virtualenv for Normandy and activate it:
virtualenv venv source ./venv/bin/activate
Whenever you want to work on Normandy in a new terminal you’ll have to re-activate the virtualenv. Read the virtualenv documentation to learn more about how virtualenv works.
Install the dependencies using pip:
pip install -r requirements/default.txt
- Errors during pip install
How to troubleshoot errors during
Install frontend dependencies using yarn and build the frontend code using npm:
yarn install npm run build
Create a Postgres database for Normandy. By default it is assumed to be named
By default, it will connect to
localhostusing the global
postgresuser. If you use a different name for the database, or otherwise want to customize how you connect to the database, you may specify the database URL by adding the following to a
.envfile at the root of the repo:
Initialize your database by running the migrations:
python manage.py migrate
Create a new superuser account:
python manage.py createsuperuser
Pull the latest geolocation database using the
Load actions into the database:
python manage.py update_actions
Update product details:
python manage.py update_product_details
- Load in initial data:
python manage.py initial_data
Once you’ve finished these steps, you should be able to start the site by running:
runsslserver.sh command automatically creates a self-signed
certificate in the
etc/ssl directory of the repository. When viewing the
site for the first time, you will have to create a certificate exception to
allow Firefox to accept the certificate and access the site over HTTPS.
The site should be available at https://localhost:8000/.
If you want to execute recipes on your local instance using the recipe client, you’ll need to set up Autograph to sign recipes as you save them:
Follow the Autograph installation instructions to launch a development instance of Autograph.
Add the following configuration to
.env(create the file if it does not exist yet):
DJANGO_AUTOGRAPH_URL=http://localhost:8765/ DJANGO_AUTOGRAPH_HAWK_ID=normandev DJANGO_AUTOGRAPH_HAWK_SECRET_KEY=3dhoaupudifjjvm7xznd9bn73159xn3xwr77b61kzdjwzzsjts
With the configuration in place, you should see log messages when saving recipes that look like this:
INFO 2017-05-01 19:58:04,274 normandy.recipes.models Requesting signatures for recipes with ids  from Autograph INFO 2017-05-01 19:58:04,301 normandy.recipes.utils Got 1 signatures from Autograph
If you want to automatically enforce Normandy code style guidelines, you can use the Therapist pre-commit hook. To install Therapist, simply run:
pip install therapist
After that, you should be able to run the following to set up the git pre-commit hook:
After that, whenever you make a new commit Therapist will check the changed code. This will save time when submitting pull requests.
If you want Therapist to attempt to automatically fix linting issues you can install the hook using:
therapist install --fix
If you ever need to bypass Therapist, you can do so by passing
--no-verify to your
git commit command.