Installation

Source Optics is a Django web application.

It also has some simple backend management CLI commands that can be run manually, that eventually should be moved to cron or another scheduler once you are in production mode.

If you have deployed one Django app, this one should not be very different. If not, this should still be fairly easy.

Source Optics uses a PostgreSQL database, and can be installed on the same VM as that database.

SourceOptics can scan repos from any HTTP/HTTPS git server (public repos only) or SSH based repositories (public or private) from any source control management system that supports Git. Automated repository imports are optional and are covered in a later section.

The app works on Mac, Linux, and Unix machines.

Instructions will assume your system has Python 3 installed, and 'pip' points at pip3 (otherwise just substitute pip3), and you have a PostgreSQL instance running. 'git' and 'expect' must also be in your path.

If you are running from homebrew, also install 'timeout', which gets installed as gtimeout'.

If you are developing on a Mac, try "Postgres.app" to simplify running the database server.

"pgadmin" works as a good database admin console, but it is not required.

Initial Steps


cd /opt
git clone https://bitbucket.org/laserllama/sourceoptics.git
cd /opt/sourceoptics
mkdir -p /etc/source_optics/conf.d/
pip install -r requirements.txt

Database Setup

Once PostgreSQL is installed, make a new database:
createdb source_optics
Next, we'll create a role for whatever username you would like to run source_optics as:
createuser --createdb 
(You may need to run these commands sudoed to 'postgres' depending on your plaform setup) From the 'psql' prompt you will then need to create a new role to allow database access:
CREATE ROLE  WITH CREATEDB SUPERUSER;
ALTER DATABASE source_optics OWNER TO ;
Add your database configuration settings to /etc/source_optics/conf.d/database.py:
DATABASES = {
            'default': {
                        'ENGINE': 'django.db.backends.postgresql',
                        'USER': '',
                        'NAME': 'source_optics',
                        'HOST': '127.0.0.1',
                        'PASSWORD' : 'databasePass',
                    }
            }

Continuing Setup

python manage.py migrate
python manage.py createsuperuser
python manage.py generate_secret
python manage.py runserver 0:8000
The generate_secret command generates a symetric key in /etc/source_optics/cred.key. If you lose this file you will need to run the command again and re-edit any credential objects in Django Admin to allow them to be re-encrypted with a new key. There are no uses for this file outside the credential objects. This will be explained in more detail later.

Django Admin and Object Setup

Now it's time to configure your newly installed instance. See Admin UI.