There are two parts to our development environment; CR Connect Workflow, and everything else.
CR Connect Workflow is the Python code we will modify. We need a local copy of it to work with.
Everything else includes CR Connect Front End, CR Connect BPMN, Protocol Builder Mock, and the Database.
We will manage CR Connect Workflow, and use Docker to manage everything else.
----------------------
Stack Deploy Generator
----------------------
Stack Deploy Generator is a Python script `stackdeploy-generator.py` that generates a docker compose file from a template. We use the docker compose file to manage the CR Connect Application Stack.
You can modify the output of Stack Deploy Generator--by passing arguments to the script or editing its default values, to fit your development process.
The arguments are in `args.csv` and the default values are in `defaults.csv`.
For class, we will use the Stack Deploy script to manage everything except CR Connect Workflow, which we will manage ourselves to allow local development.
We will clone the CR Connect Workflow repository locally, and configure the stack deploy environment to work with our local copy of Workflow. Then, we can still use Stack Deploy to manage the rest of the stack.
------------------
Deployment Example
------------------
Here is a step by step process for deploying CR Connect with Stack Deploy.
Working Directory
-----------------
Create a working directory in a suitable location.
..code-block::
mkdir development
cd development
We will use `development` as the top level of our example directory structure.
Clone from github
-----------------
Clone CR Connect Workflow and the Stack Deploy scripts in the development directory.
We also need to comment out 2 lines where bpmn and the front end depend on the backend.
..code-block::
bpmn:
container_name: bpmn
depends_on:
- db
# - backend
- pb
..code-block::
frontend:
container_name: frontend
depends_on:
- db
# - backend
image: sartography/cr-connect-frontend:dev
Modify CR Connect Workflow
--------------------------
We now need to modify CR Connect Workflow so it talks to the correct ports in the docker container.
The defaults for the docker container are
..code-block::
# Backend: 5000
# Protocol builder : 5001
# Bpmn: 5002
# Db: 5003
# Frontend : 5004
We only need to worry about 5003 for the database and 5004 for the front end. Everything else matches already.
Instance Config
---------------
Flask has a built-in mechanism for modifying your configuration for local development. You can put your modifications into a **config.py** file in the **instance** directory.
Note that you may need to create the instance directory and config.py file.
Flask will read from the config.py file after loading its default configuration. The instance configuration entries will override the default configuration.
..code-block::
cd development/cr-connect-workflow
Create the instance directory if it does not already exist.
..code-block::
mkdir instance
Change to the instance directory
..code-block::
cd instance
Create config.py if it does not already exist.
..code-block::
touch config.py
Edit config.py
--------------
These two lines tell the backend that the front end runs on port 5004, and to allow CORS for that port.