Development environment
To start with developing on Zou, you need Python 3 installed and a Postgres database instance.
Database
To run Postgres, we recommend using Docker (it's simpler, and it won't impact your local system):
sudo docker pull postgres
sudo docker run \
--name postgres \
-pĀ 5432:5432 \
-e POSTGRES_PASSWORD=mysecretpassword \
-d postgres
Key-value store
To run Redis, we recommend using Docker again:
sudo docker pull redis
sudo docker run \
--name redis \
-p 6379:6379 \
-d redis
Indexer
To run Meilisearch, we recommend using Docker again:
sudo docker pull getmeili/meilisearch:v1.8.3
sudo docker run -it --rm \
--name meilisearch \
-p 7700:7700 \
-e MEILI_ENV='development' \
-e MEILI_MASTER_KEY='meilimasterkey' \
-v $(pwd)/meili_data:/meili_data \
-d getmeili/meilisearch:v1.5
FFMPEG
For video operations, FFMPEG is required. For that, install it through your OSĀ package manager:
sudo apt-get install ffmpeg
Source and dependencies
Then get Zou sources:
git clone git@github.com:cgwire/zou.git
Install virtualenvwrapper
:
pip install virtualenvwrapper
Add configuration for virtualenvwrapper
to your .bashrc:
export WORKON_HOME=directory_for_virtualenvs
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source ~/.local/bin/virtualenvwrapper.sh
Create a virtual environment with mkvirtualenv
:
mkvirtualenv zou
workon zou
Install dependencies:
pip install -r requirements.txt
Init data
Create a database in Postgres named zoudb
with user postgres
and password
mysecretpassword
. Then init db:
python zou/cli.py clear-db
python zou/cli.py init-db
python zou/cli.py init-data
Create a first user:
python zou/cli.py create-admin super.user@mycgstudio.com --password=mysecretpassword
Run server:
PREVIEW_FOLDER=$PWD/previews DEBUG=1 MAIL_DEBUG=1 FLASK_DEBUG=1 FLASK_APP=zou.app INDEXER_KEY=meilimasterkey python zou/debug.py
You can now use the API by requesting http://localhost:5000
.
Update database
In case of adding/removing attributes of models, you must generate the DB update file:
python zou/cli.py migrate-db
Event server
To run the Server Events server used to update the web GUI in realtime, use the following command.
gunicorn --worker-class geventwebsocket.gunicorn.workers.GeventWebSocketWorker -b 127.0.0.1:5001 -w 1 zou.event_stream:app
Tests
To run unit tests, we recommend using another database.
Create a testing database
In the CLI of the hosting, the PostgreSQL DB executes the following:
If Docker, connect with: docker exec -it postgres bash
sudo su -l postgres
psql -c 'create database zoutest;' -U postgres
Run the tests
In your zou environment workon zou
, execute the tests with the DB_DATABASE
environment variable:
DB_DATABASE=zoutest py.test
If you want to run a specific test (you can list several):
DB_DATABASE=zoutest py.test tests/models/test_entity_type.py
Debug email sending
If you set properly the MAIL_DEBUG=1
flag, the body of each sent email is
displayed in the console.