Installation

Clone the Repositories

Clone the following repositories from the Digital Factory Geofencing project.

  • workspace
    • Root directory
  • geofencing
    • Holds the actual geofencing application. This should be cloned into the workspace/apps directory
    • In the readme file for this repository lists the remaining repositories that need to be cloned.
    • It must also be noted that the prometheus repository must be installed under the middleware package.

Clone the repositories:

git clone git@bitbucket.org:digitalfactory/workspace.git
cd workspace/apps/
git clone git@bitbucket.org:digitalfactory/geofencing.git

Linux OS Users If using a Linux operating system such as Ubuntu, you can run the following script from the workspace repository. This will handle the cloning of all remaining repositories.

workspace/setup
./setup.sh

Mac OSX Users If using a Mac, you can run the mac_os_setup.sh script to install all of the python application dependencies. From your workspace repository run the following bash script.

cd workspace/setup
./mac_setup.sh

Navigate to the geofencing repository and run the setup.sh script located there.

cd apps/geofencing
./setup.sh

Update the application security keys

To run the application, you will need to update the workspace/apps/geofencing/apikeys/custom.py file with your developer API credentials. Do not add this file to git for version control.

from default import DefaultSecurityKeys


class CustomSecurityKeys(DefaultSecurityKeys):
    AWS_ACCESS_KEY_ID = '<ENTER YOUR AWS ACCESS KEY'
    AWS_SECRET_ACCESS_KEY = '<ENTER YOUR AWS SECRET KEY>'

    GOOGLE_AUTH_KEY = '<ENTER GOOGLE API KEY>'

    MONGODB_SETTINGS = {
        'USERNAME': '<ENTER YOUR MONGODB USERNAME>',
        'PASSWORD': '<ENTER YOUR MONGODB PASSWORD'
    }

Create your Virtual Python Environment

If configuring you environment by way of the setup.sh scripts described above, the installation of Virtualenv and creation of your first virtual environment called “env”. To initialize your virtual python environment use the following command:

source <path to virtualenv folder>/bin/activate

To deactivate the environment:

deactivate

To create a new virtual environment:

virtualenv <environment_name>

For more details on configuring your virtual environment see the link below: See this url for instructions on how to install and create your virtual environment. `https://virtualenv.pypa.io/en/stable/

Pip Installation Dependencies

You can find all of the required pip dependencies in the setup.sh file

Database Installation

The following databases servers need to be installed. If using linux, the setup.sh files handle the core installation already. However additional manual steps are still needed for run-time configurations.

  • MongoDB
  • SQLite
  • PostgreSQL

Installation instructions for OSX users

Follow the MongoDB installation please see this Trello card

PostgreSQL installation instructions - See this Trello card

SQLite will be installed automatically with the Flask application.

Commands Application Management

The general syntax structure for each command is

python <path to manage.py>/manage.py -a <application name> -c <deployment enviornment> <command>

The manager package under workspace hosts the scripts that are used to facilitate CLI execution. See Flask-Script for more details.

Use the command below to run the local dev server:

python manager/manage.py -a geofencing -c test runserver

To initialize the database and add basic test data i.e. users, accounts, geofences and basic content

python manage.py -a geofencing -c test setup_dbs

Note the above command should be ran from inside the workspace/manger package*

To generate an API token to perform manual testing of the APIs

python manager/manage.py -a geofencing -c test create_token -u demo-user-1 -ac Digital-Factory-Demo

*Note the above command should be ran after the database has been initialized.