Skip to content

Instantly share code, notes, and snippets.

@gregelin
Last active November 17, 2020 09:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregelin/ad052861ac640055aad6c877d53ad6c2 to your computer and use it in GitHub Desktop.
Save gregelin/ad052861ac640055aad6c877d53ad6c2 to your computer and use it in GitHub Desktop.
Developing Compliance Apps

About

Step-by-step guide to creating compliance apps using docker version of GovReady-Q Commpliance Server.

Create Directories for Development

We need a place to download GovReady's install script, a place for GovReady's local sqlite database, and finally a place to store our apps for local development.

These places can be any directory path. For simplicity, let's create a single directory to store the install script and sqlite database and a subdirectory for local compliance app development.

mkdir /path/to/dev_directory
cd /path/to/dev_directory
mkdir /path/to/dev_directory/apps

Example:

mkdir ~/govreadydev
cd ~/govreadydev/
mkdir ~/govreadydev/apps

Install GovReady-Q Compliance Server

Let's next download GovReady's docker_container_run.sh script. This script simplifies passing various configuration settings to the govready-q docker container that we will need for local development.

wget https://raw.githubusercontent.com/GovReady/govready-q/master/deployment/docker/docker_container_run.sh
chmod +x docker_container_run.sh

The docker_container_run.sh supports a variety of advanced configuration settings via command line parameters. The ones we care about for developing compliance apps are:

  • --address mydomain.com:port
  • --appsdevdir /path/to/apps
  • --sqlitedb /path/to/govready-q-database.sqlite

Example

./docker_container_run.sh --address localhost:8090 --sqlitedb ~/govreadydev/govready-q-database.sqlite --appsdevdir ~/govreadydev/apps 

Here is an example using the docker image of the cutting-edge nightly build, govready-q-nightly.

./docker_container_run.sh --image govready/govready-q-nightly --address localhost:8090 --sqlitedb ~/govreadydev/govready-q-database.sqlite --appsdevdir ~/govreadydev/apps 

NOTE: You will be alerted if you have an existing version of govready-q running. Just follow instructions to resolve and then re-run your docker_container_run.sh command with your parameters.

The script will report the URL to visit. It could take a few minutes for the docker image to be downloaded, extracted, and spun up locally, especially if this is your first pull.

Setup Organization

Now that our GovReady-Q Compliance Server is running, we need to create a superuser account and an organization. Fortunately, our docker image comes complete with script for that purpose. Run the following script and answer the prompts.

docker container exec -it govready-q ./first_run.sh

Your prompt and reply will look something like this:

Installed 2 object(s) from 1 fixture(s)
Let's create your first Q user. This user will have superuser privileges in the Q administrative interface.
Username: amelia
Email address: amelia@mydomain.com
Password: 
Password (again): 
Superuser created successfully.
Let's create your Q organization.
Organization Name: Cool Complany

Now return to the URL and notice the company name has updated.

Congratulations to us! We've installed GovReady-Q Compliance Server configured for local development of compliance apps!

You can now sign in.

Create AppSource

Our final configuration step is to tell GovReady-Q where to look for the apps we are going to develop. Remember the directory you previously set up to hold your apps? Let's tell GovReady-Q to use that directory as a local "AppSource."

docker container exec -it govready-q ./manage.py compliance_app mysource --path path/to/apps

Example

docker container exec -it govready-q ./manage.py compliance_app mysource --path ~/govreadydev/apps

Create App Stub files

Let's create our first commpliance app! Use the below command and replace newappname with the name of your app. Then reload the docker image to restart GovReady-Q

docker container exec -it govready-q ./manage.py compliance_app host newappname
docker container restart govready-q

Example

docker container exec -it govready-q ./manage.py compliance_app host awsglacial
docker container restart govready-q

Our new compliance app will appear in our compliance app catalog with the name "New Compliance App" and as a new folder in our development directory.

├── apps
│   └── newappname
│       ├── app.yaml
│       ├── assets
│       │   └── app.png
│       └── example.yaml
├── docker_container_run.sh
└── govready-q-database.sqlite

Example

├── apps
│   └── awsglacial
│       ├── app.yaml
│       ├── assets
│       │   └── app.png
│       └── example.yaml
├── docker_container_run.sh
└── govready-q-database.sqlite

Editing Compliance App

We can edit our "New Compliance App" by editing it's app.yaml and example.yaml file on disk in our favorite text editor or with GovReady-Q's built-in authoring tools.

After each edit to the compliance apps files on disk via your editor, it will be necessary to restart the docker container and reload a new instance of the compliance app to see your changes. GovReady-Q purposely does not automatically recognize changes to compliance apps until a new instance of the app is selected. This insures previously loaded versions of the compliance app correctly maintain data after incompatible changes in new versions of the app.

Restarting GovReady-Q to clear compliance app catalog cache after updating compliance app files on disk.

docker container restart govready-q

When editing the compliance app via GovReady-Q's built-in authoring tools, you will immediately see the changes in the instance of the compliance app you are editing and the changes are written to the files on disk. If you want to load a fresh version of the compliance app you've been editing, you will need to restart the docker image to clear the previous version of the compliance app from the cache with the above command.

GovReady-Q's built-in authoring tools will let you edit and add questions, but currently won't let you change the name of the description of the app in catalog. You will still need to edit those details in the compliance app files stored on disk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment