4. Setup development environment

4.1. Source Code

$ git clone https://github.com/release-engineering/product-definition-center.git

4.2. Installation

4.2.1. Option 1: Start it on RPM

For development purposes, install following dependencies:

4.2.2. Option 2: Start it on virtualenv

  • Koji is not available on PyPI. You must install the koji package to your system via yum before creating a virtualenv.

    $ sudo yum install koji
    
  • After that, run

    $ pip install virtualenvwrapper
    

    and setup according to ‘Setup’ steps in /usr/bin/virtualenvwrapper.sh. Then run

    $ mkvirtualenv pdc --system-site-packages
    

    to include koji into your pdc virtualenv.

  • Run the following

    $ workon pdc
    $ pip install -r requirements/devel.txt
    

    to activate pdc virtualenv and install all the dependencies.

4.2.3. Option 3: Start it on Docker

  • Install Docker: see the official installation guide for details. Generally, it might be enough to run install it with yum and the run it.

    $ sudo yum install docker-engine
    $ sudo service docker start
    
  • Use this command to build a new image

    $ sudo docker build -t <YOUR_NAME>/pdc <the directory your Dockerfile is located>
    
  • Run the container

    $ docker run -it -P -v $PWD:$PWD <YOUR_NAME>/pdc python $PWD/manage.py runserver 0.0.0.0:8000
    
  • Check the address

    1. Find the address of the docker machine (127.0.0.1 –> DOCKER_HOST).

    2. Find the mapped port of your running container

      $ sudo docker ps -l --> PORT
      
  • Access it by visiting DOCKER_HOST:PORT in your web browser.

4.3. Customize settings

You can use the dist settings template by copying it to settings_local.py:

$ cp settings_local.py.dist settings_local.py

Feel free to customize your settings_local.py. Changes will be populated automatically. In local development environment, you may need to set DEBUG = True to get better error messages and comment out ALLOWED_HOSTS setting.

For development you might also consider uncommenting REST_FRAMEWORK section but keeping nested DEFAULT_PERMISSION_CLASSES item commented. This will disable authentication.

4.4. Init database

To initialize database, run:

$ python manage.py migrate --noinput

4.5. Run devel server

To run development server, run:

$ make run

For development you may find it useful to enable Django Debug Toolbar.

Related settings is documented in comment at the to of settings_local.py.dist.