pwhipp / cobpc

COBPC Member portal
0 stars 0 forks source link

cobpc

COBPC Member portal

All of the portal code and related documentation will go in this repository.

It may also include the canonical club documents, role definitions etc.

Installation and deployment

These instructions are for installing on Debian 8 or Ubuntu 16.04 servers (later versions are probably ok).

Prerequisites

Deployment

If deploying remotely, set up nginx and a separate user for the service (e.g. cobpc). Ensure whatever user you are using has access to the github repository

  1. Create a virtual environment running python 3.7 e.g:

    virtualenv --python=`which python3.7` website

  2. Activate the environment (website)

    cd website && . bin/activate

  3. Clone the repo into a subfolder in website

    git clone git@github.com:pwhipp/cobpc.git

  4. Link the environment set up into the virtual env

    ln -s ${VIRTUAL_ENV}/cobpc/deploy/postactivate bin && . bin/postactivate

  5. Install the requirements

    pip install -r cobpc/requirements.txt

  6. Create a local configuration (may want to edit it)

    cp cobpc/core/settings/includes/local.example.py local.py

  7. Set up the database

    django migrate

  8. Build the html documentation

    django devdoc --no_open

  9. For development you can now run the service and work on it. Run it with

    django runserver

  10. For production you need to ensure that the service is run in a more robust manner:

    1. Hook up nginx

      sudo ln -s /home/cobpc/website/cobpc/deploy/nginx.cfg /etc/nginx/sites-available/cobpc

      sudo ln -s /etc/nginx/sites-available/cobpc /etc/nginx/sites-enabled

      sudo systemctl reload nginx

    2. Link the service file so systemD can find it, enable it and start it:

      sudo ln -s /home/cobpc/website/cobpc/deploy/cobpc.service /etc/systemd/system

      systemctl start cobpc

      systemctl enable cobpc

    3. When updating or installing on production for the first time static files must be collected

      django collectstatic