Welcome¶
push-dev-dashboard is the code for Mozilla Developer Services dashboard - where web developers can manage how their web apps and sites use services like Mozilla Push Service.
Resources¶


Code: | |
---|---|
License: | MPL2 |
Documentation: | |
Issues: | https://github.com/mozilla-services/push-dev-dashboard/issues |
CI: | https://travis-ci.org/mozilla-services/push-dev-dashboard (unit tests) https://circleci.com/gh/mozilla-services/push-dev-dashboard (deployment artifacts) https://services-qa-jenkins.stage.mozaws.net:8443/job/push-dashboard_e2e-test_prod/ (selenium/integration tests) |
Servers: | https://pushdevdashboard-default.stage.mozaws.net/ (stage) https://push-dashboard.services.mozilla.com/ (prod) |
IRC: |
Contents¶
Development¶
Requirements¶
- python 2.7, virtualenv, pip for app server
- npm for front-end testing
Install Locally¶
Clone and change to the directory:
git clone git@github.com:mozilla-services/push-dev-dashboard.git cd push-dev-dashboard
Create and activate a virtual environment (Can also use virtualenvwrapper):
virtualenv env source env/bin/activate
-
pip install -r requirements-dev.txt npm install npm link stylus yuglify
Copy the
.env-dist
file to.env
:cp .env-dist .env
Source the
.env
file to set environment config vars (Can also use autoenv):source .env
`Migrate`_ DB tables
python manage.py migrate
-
python manage.py createsuperuser
Run it¶
Source the
.env
file to set environment config vars (Can also use autoenv):source .env
Activate the virtual environment (Can also use virtualenvwrapper):
source env/bin/activate
Run it:
python manage.py runserver
Enable Firefox Accounts Auth¶
To enable Firefox Accounts authentication, you can use our local development OAuth client app.
- Add a django-allauth social app for Firefox Accounts (Log in as the
superuser account you created):
- Provider: Firefox Accounts
- Name: fxa
- Client id: 7a4cd4ca0fb1b5c9
- Secret key: c10059ba24e6715a1b6f2c80f1cc398fb6a39ca18bc7554e894b36ea85b88eeb
- Sites: example.com -> Chosen sites
- Log out of the admin account
- Sign in with a Firefox Account at http://127.0.0.1:8000.
Run in production mode¶
Follow these steps to emulate production (for example, to test compressed assets). Run all commands from the project root.
- Stop
runserver
if it’s already running - In .env, set
DJANGO_DEBUG
toFalse
- Run
python manage.py collectstatic
- Install stunnel
- Mac:
brew install stunnel
- Mac:
- Run this command to generate a local cert and key for stunnel (you can use
the default values for all prompts):
openssl req -new -x509 -days 9999 -nodes -out stunnel/stunnel.pem -keyout stunnel/stunnel.pem
- Run
stunnel stunnel/dev_https
- In another terminal, run
HTTPS=1 python manage.py runserver 127.0.0.1:5000
- Go to https://127.0.0.1:8443 to confirm the certificate exception and browse the site
Working on Docs¶
Install doc requirements:
pip install -r requirements-docs.txt
Building the docs is easy:
cd docs
sphinx-build . html
Read the beautiful docs:
open html/index.html
Updating Translations¶
Run
makemessages
to make updateddjango.po
files:python manage.py makemessages --keep-pot
Commit the updates to git:
git add locale git commit -m "Updating translations {YYYY-MM-DD}"
Adding a Translation¶
First, Update translations
Make the new
{locale}
directory for the new language:mkdir locale/{locale}
Run
makemessages
to make thedjango.po
file for it:python manage.py makemessages -l {locale}
Add the new directory to git:
git add locale/{locale} git commit -m "Adding {locale} locale"
Testing¶
Back-end python tests¶
Install test requirements:
pip install -r requirements-test.txt
Run the test suites:
python manage.py test
Back-end style tests¶
Install test requirements:
pip install flake8
Run the test suites:
flake8 .
Front-end style tests¶
Install test requirements:
npm install
Run the test suites:
npm test
Translation lint tests¶
Install test requirements:
pip install -r requirements-l10n.txt
Run the test suites:
cd locale dennis-cmd lint .
Selenium/Integration tests¶
Install test requirements:
pip install -r requirements-test.txt
Set environment variables in
.env
file:DJANGO_DEBUG_TOOLBAR=False TESTING_WEBDRIVER_TIMEOUT=10 TESTING_FXA_ACCOUNT_EMAIL=tester@test.com TESTING_FXA_ACCOUNT_PASSWORD=testpass
- Required
DJANGO_DEBUG_TOOLBAR
- The django debug toolbar interferes with selenium clicking on the sign-in button; disable it. NOTE: Make sure you restart the django process. - Required
TESTING_WEBDRIVER_TIMEOUT
- Number of seconds selenium/Firefox will wait before timing out. Default is0
which skips selenium test. - Required
TESTING_FXA_ACCOUNT_EMAIL
- Email of Firefox Account to use during tests. - Required
TESTING_FXA_ACCOUNT_PASSWORD
- Password of Firefox Account to use during tests. TESTING_SITE
- The dashboard domain/site that selenium/Firefox will use. Default ishttp://127.0.0.1:8000
TEST_PUSH_SERVER_URL
- Thedom.push.serverURL
that selenium/Firefox will use. Default is the dev environment:wss://benpushstack-1704054003.dev.mozaws.net/
Note: Make sure the Push Messages API server inPUSH_MESSAGES_API_ENDPOINT
matches this push server.
- Required
Run the test suites:
python manage.py test
Deployment¶
push-dev-dashboard is designed with 12-factor app philosophy, so you can easily deploy your changes to your own app.
Deploy onto Deis¶
Note: Mozilla used to run our own Deis cluster, but it has been shut down. The following instructions should work to deploy the code to your own Deis cluster.
Create the application:
deis create dev-dashboard-username
Push code to the deis remote:
git push deis master
Create an RDS Postgres instance in us-east-1 with default settings except:
- DB Instance Class: db.t2.micro
- Allocated Storag: 5 GB
- VPC: vpc-9c2b0ef8
In the RDS Instance configuration details, click the “Security Groups”. (Usually something like “rds-launch-wizard-N (sg-abcdef123)”)
In the security group, under the “Inbound” tab, change the source to allow the deis cluster hosts.
Set the
DATABASE_URL
environment variable to match the RDS DB:deis config:set DATABASE_URL=postgres://username:password@endpoint/dbname
Migrate DB tables on the new RDS instance:
deis run python manage.py migrate
Dock to app instance to create a superuser:
deisctl dock dev-dashboard-username /app/.heroku/python/bin/python manage.py createsuperuser
Open the new deis app:
deis open
Enable Firefox Accounts Auth on your Deis app¶
To enable Firefox Account sign-ins on your Deis app, you will need to create your own Firefox Accounts OAuth Client for your app domain.
Go to register your own Firefox Accounts OAuth Client:
- Client name: dev-dashboard-username
- Redirect URI: https://<your-push-dev-dashboard-app-on-deis-domain>/accounts/fxa/login/callback/
- Trusted Mozilla Client: CHECKED
Be sure to copy the client secret - you can’t see it again.
Go to https://<your-push-dev-dashboard-app-on-deis-domain>/admin/socialaccount/socialapp/add/ to Enable Firefox Accounts Auth like a local machine; this time using your own new Firefox Accounts OAuth Client ID and Secret
Sign in at https://<your-push-dev-dashboard-app-on-deis-domain>/ with a Firefox Account.
Run-book¶
push-dev-dashboard is written as a monolithic django application with 2 processes. It’s written with 12 factor methodology, so it is configured almost entirely by environment variables.
Travis CI is used for unit, docs, l10n, and coding style tests before code lands in master.
Circle CI is used to build docker containers for deployment.
Jenkins is used to run the selenium integration tests on deployments to the stage and production servers.
Processes¶
Web¶
The web process is a django web app run by gunicorn. It is defined as the
CMD
instruction in the Dockerfile
.
clock¶
The clock process is a python script run by the django_extensions
runscript
command defined in Procfile
. It uses APScheduler
to call
the start_recording_push_apps
django command.
Environment Variables¶
- REQUIRED
DATABASE_URL
- database connection url. See thedj-database-url
URL schema reference - REQUIRED
PUSH_MESSAGES_API_ENDPOINT
- endpoint for Push Messages API. - REQUIRED
FXA_OAUTH_ENDPOINT
- endpoint for FxA oauth provider. See thedjango-allauth
Firefox Accounts reference. - REQUIRED
FXA_PROFILE_ENDPOINT
- endpoint for FxA profile. See thedjango-allauth
Firefox Accounts reference.