cr-connect-tutorial/02_environment/00_index.rst

198 lines
4.3 KiB
ReStructuredText
Raw Normal View History

.. _index-development-environment:
2021-05-10 17:38:15 +00:00
=======================
Environment
2021-05-10 17:38:15 +00:00
=======================
This section covers how to install a development environment for developing CR Connect.
2021-05-10 17:38:15 +00:00
.. Note::
2021-05-10 17:38:15 +00:00
To set up your environment, you need Python 3, node.js, Angular, and Docker installed.
2021-05-10 17:38:15 +00:00
Here is a step by step process for installing the code bases.
2021-05-10 17:38:15 +00:00
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.
2021-05-10 17:38:15 +00:00
Clone from github
-----------------
As we mentioned in the introduction, CR Connect is a collection of code bases.
2021-05-10 17:38:15 +00:00
For development, we have to clone 4 git repositories; CR Connect Workflow, CR Connect BPMN,
CR Connect Frontend, and PB Mock.
2021-05-10 17:38:15 +00:00
From inside the **/development** directory.
2021-05-10 17:38:15 +00:00
.. code-block::
git clone https://github.com/sartography/cr-connect-workflow.git
2021-05-10 17:38:15 +00:00
git clone https://github.com/sartography/cr-connect-bpmn.git
2021-05-10 17:38:15 +00:00
git clone https://github.com/sartography/cr-connect-frontend.git
2021-05-10 17:38:15 +00:00
git clone https://github.com/sartography/protocol-builder-mock.git
2021-05-10 17:38:15 +00:00
This creates four directories.
2021-05-10 17:38:15 +00:00
.. code-block::
$ ls -l
total 0
drwxr-xr-x 23 michaelc staff 736 Jun 7 16:04 cr-connect-bpmn
drwxr-xr-x 25 michaelc staff 800 Jun 7 16:04 cr-connect-frontend
drwxr-xr-x 31 michaelc staff 992 Jun 7 16:04 cr-connect-workflow
drwxr-xr-x 22 michaelc staff 704 Jun 7 16:04 protocol-builder-mock
2021-05-10 17:38:15 +00:00
Pipenv
------
2021-05-10 17:38:15 +00:00
We need to install **pipenv**, which we use to maintain our Python packages and virtual environment.
2021-05-10 17:38:15 +00:00
Use pip3, which comes with Python3. (You can run this command from any directory.)
2021-05-10 17:38:15 +00:00
.. code-block::
pip3 install pipenv
2021-05-10 17:38:15 +00:00
CR Connect Workflow
-------------------
2021-05-10 17:38:15 +00:00
Next, we will use **pipenv** to set up CR Connect Workflow.
2021-05-10 17:38:15 +00:00
From inside the **/development/cr-connect-workflow** directory:
2021-05-10 17:38:15 +00:00
.. code-block::
pipenv install --dev
2021-05-10 17:38:15 +00:00
Pipenv creates a Python virtual environment, and installs all our dependencies.
2021-05-10 17:38:15 +00:00
You can see the location of the virtual environment
2021-05-10 17:38:15 +00:00
.. code-block::
pipenv --venv
2021-05-10 17:38:15 +00:00
You should see a path with the location to your virtual environment, something like this.
2021-05-10 17:38:15 +00:00
.. code-block::
~/.local/share/virtualenvs/cr-connect-AYWZ0UOE
2021-05-10 17:38:15 +00:00
.. Note::
2021-05-10 17:38:15 +00:00
If you use Visual Studio on Windows, and have trouble installing the python-Levenshtein package,
you might need to download the build tools.
https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16
2021-05-10 17:38:15 +00:00
Postgres
--------
2021-05-10 17:38:15 +00:00
We use Postgres for a database, and we deploy it with Docker.
2021-05-10 17:38:15 +00:00
Inside the **/development/cr-connect-workflow** directory,
there is a **postgres** directory containing scripts and Docker files to manage the Postgres install.
2021-05-10 17:38:15 +00:00
From the **/development/cr-connect-workflow/postgres** directory:
2021-05-10 17:38:15 +00:00
.. code-block::
docker-compose up
2021-05-10 17:38:15 +00:00
This should create and start up the databases.
There are four databases; **crc_dev**, **crc_test**, **pb**, and **pb_test**.
2021-05-10 17:38:15 +00:00
The databases ending in **_test** are used when we run tests.
2021-05-10 17:38:15 +00:00
We now need to create the tables and add some example data.
2021-05-10 17:38:15 +00:00
From the **/development/cr-connect-workflow** directory
2021-05-10 17:38:15 +00:00
.. code-block::
pipenv run flask db upgrade
2021-05-10 17:38:15 +00:00
pipenv run flask load-example-data
2021-05-10 17:38:15 +00:00
Run Backend
-----------
2021-05-10 17:38:15 +00:00
At this point we should be able to run the backend.
2021-05-10 17:38:15 +00:00
.. code-block::
pipenv run python run.py
2021-05-10 17:38:15 +00:00
You can test by loading the web page at http://localhost:5000/v1.0/ui/#/
2021-05-10 17:38:15 +00:00
PB Mock
-------
2021-05-10 17:38:15 +00:00
Installing PB Mock is similar to CR Connect Workflow.
2021-05-10 17:38:15 +00:00
From the **/development/protocol-builder-mock** directory:
2021-05-10 17:38:15 +00:00
.. code-block::
pipenv install --dev
2021-05-10 17:38:15 +00:00
pipenv run python run.py
CR Connect BPMN
---------------
CR Connect BPMN is written in Angular, so the install is different from CR Connect Workflow and PB Mock.
From the **/development/cr-connect-bpmn** directory:
2021-05-10 17:38:15 +00:00
.. code-block::
npm install
2021-05-10 17:38:15 +00:00
ng serve
2021-05-10 17:38:15 +00:00
CR Connect Frontend
-------------------
2021-05-10 17:38:15 +00:00
CR Connect Frontend is also Angular, and works just like CR Connect BPMN.
2021-05-10 17:38:15 +00:00
From the **/development/cr-connect-frontend** directory:
2021-05-10 17:38:15 +00:00
.. code-block::
npm install
2021-05-10 17:38:15 +00:00
ng serve
2021-05-10 17:38:15 +00:00
URLs
----
You should now be able to reach all four locations:
2021-05-10 17:38:15 +00:00
- `API <http://localhost:5000/v1.0/ui/>`_
2021-05-10 17:38:15 +00:00
- `Dashboard <http://localhost:5004/app/home>`_
2021-05-10 17:38:15 +00:00
- `Configurator <http://localhost:5002/bpmn/home>`_
2021-05-10 17:38:15 +00:00
- `PB Mock <http://localhost:5001>`_