Project provide two mode environments is development and production, the development environment used when development process and the production environment used to deployed in server You can run the project on your local environment with these steps:
- Setup python virtual environment and install libraries
-
To create virtual environment, run command:
python3 -m venv venv
Or you can use Add Interpreter in PyCharm
-
Activity virtual environment in ubuntu:
source venv/bin/activate -
Install libraries
pip3 install -r requirements.txt
-
Start Trava API in
developmentmode
To start API with development environment, simply you runmake rundev
If you want to run project with custom environment, you run following:
make rundocker
You want to run project directly without docker, run following:
make run
-
to get more information, you can run:
make help -
After your app ran, you can follow here to test api
-
How to execute database docker container
docker exec -it dev_sanic_sql_container bash -
Login default user with password is sanic
mysql -u root -p
-
Switching to sanic_app database
use sanic_app; -
End then you can enter your query command in console line.
My project use pre-commit to check code before pushing to git. You can find all setup and command line in here. In this article, i simply introduce some useful command line
- Install pre-commit to git hook
pre-commit install
- Run pre-commit manually
pre-commit run --all-files
- Learn command line rule
pre-commit --help