4.0 KiB
PeeringDB Deploy
PeeringDB currently only runs on python2.7 - all instructions below are to be taken with that in mind.
Getting Started
This document uses the following variables
export PDB_REPO=git@github.com:peeringdb/peeringdb.git
Install facsimile
pip install facsimile jinja2
Clone peeringdb
git clone $PDB_REPO
Developer instance deploymnet
Create ~/srv
mkdir ~/srv
Copy config/facsimile/dev.yaml
to config/facsimile/mydev.yaml
and make changes where needed.
cp config/facsimile/dev.yaml config/facsimile/mydev.yaml
vi config/facsimile/mydev.yaml
Use the facs
command to deploy a virtualenv and server files for your dev instance
facs peeringdb mydev --src-dir=.
facs venv mydev --src-dir=.
Files will be deployed to ~/srv/dev.peeringdb.com
(unless you changed the location in your config)
Setup passwords
Once you have run facs
for the first time it will have created a .facsimile directory
You will want to open .facimsile/state/{env}/state.yaml
and set the correct passwords for everything and then do
another deploy to make sure the correct passwords are deployed.
instances:
inmap: {}
uiidmap: {}
passwd:
deskpro: xxx # deskpro api key
djangokey: xxx # django secret
google_geoloc_api: xxx # google geolocation api key
peeringdb: xxx # database password
recaptcha: xxx # recaptcha secret
Create api-cache dir
mkdir ~/srv/dev.peeringdb.com/etc/api-cache
Symlink for convenience
In order to be able to run the manage.py command out of the pdb repository you can symlink the peeringdb_com directory from deploy location
In the peeringdb repo root:
ln -s ~/srv/dev.peeringdb.com/peeringdb/peeringdb_com peeringdb_com
Setup database
During deploy facsimile will have created a sql file at .facsimile/tmp/RELEASE/mydev/peeringdb/init.sql
- load it into mysql.
mysql -u root -p < .facsimile/tmp/RELEASE/mydev/peeringdb/init.sql
Migrate database - empty, from scratch
. ~/srv/dev.peeringdb.com/venv/bin/activate
./manage.py migrate
./manage.py createcachetable
./manage.py loaddata fixtures/initial_data.json
Running the dev instance
./manage.py runserver
Populating with data
There are currently 2 ways to get some data into your developer instance
- Sync from production peeringdb - slow, but accurate data
- Generate test data - fast, but marginally useful test data
1) Sync from Production
You can populate your data from peeringdb.com using
./manage.py pdb_load_data
However be prepared for this to take 15-20 minutes as it will not only sync the entities, but also set up usergroups for each organization and so forth.
This should only be used to populate initial data. Once you have started adding / updating objects and your data diverges from production data, it is no longer useful to call this command.
Special Note: this will only sync data visible to everyone, any fields or rows hidden behind authentication will be missed.
2) Generate test data
Alternatively a faster way to get data into your instance is to generate a set of test data.
The data generated has no relation to real world data, but should be good enough for testing purposes
./manage.py pdb_generate_test_data --commit
Admin
The admin area can be accessed from the /cp
endpoint, you will need to have a superuser to access it
./manage.py createsuperuser
Hangups
Authentication not working
This is usually caused by misconfigured session settings
In peeringdb_com/settings.d/01-local.conf
- Check that
SESSION_COOKIE_DOMAIN
is set to the apropriate domain - Check that
SESSION_COOKIE_SECURE
isFalse
if youre not serving over https
Versioning
Everything is versioned for deploy, using facsimile.
# to update dev versions
version_bump_dev
# to update release versions
version_merge_release
Tests
pip install -r requirements-test.txt
py.test -v -rxs --cov-report term-missing --cov=peeringdb_server/ --capture=sys tests/