You have to have the following tools installed prior initializing the project:
For easier running of everyday tasks, like:
- run dev server
- run all tests
- run linters
- run celery workers
- ...
We use invoke.
It provides shortcuts for most of the tasks, so it's like collection of bash scrips
or makefile or npm scripts.
To enable autocomletion of invoke commands add this line to your ~/.zshrc
source <(inv --print-completion-script zsh)
Also invoke abstract "python interpreter", so you can use both virtual env and
dockerized python interpreter for working with project (see .invoke file).
virtualenvis the default approach that requires python interpreter, virtualenv, etc.dockerizedis simpler for quick starting project and for experienced developers
Suggested approach is using virtualenv
Project may use external services like Database (postgres), message broker,
cache (redis). For easier set up they are defined in docker compose.yml file,
and they are automatically prepared / started when using invoke.
You can run frontend application for debugging or testing by simply using
inv frontend.run. This command clones frontend repository and puts it in the
parent dir, then installs node packages and runs application. Please, ensure you
have a compatible version of node installed
(install nvm to manage node versions).
Current node version: TODO: set current node version required for frontend app
Note: You can change link/path to frontend app repository in provision/frontend.py.
- Set up aliases for docker hosts in
/etc/hosts:
127.0.0.1 postgres
127.0.0.1 redis
- Create separate python virtual environment if you are going to run it in local:
pyenv virtualenv-delete --force ffgpt-backend
pyenv install `pyenv latest 3.11` --skip-existing
pyenv virtualenv 3.11 ffgpt-backend
pyenv local ffgpt-backend
pyenv activate ffgpt-backend- Set up packages for using
invoke
pip install -r requirements/local_build.txt- Start project initialization that will set up docker containers, python/system env:
inv project.init- Run the project and go to
localhost:8000page in browser to check whether it was started:
inv django.runThat's it. After these steps, the project will be successfully set up.
Once you run project.init initially you can start web server with
inv django.run command without executing project.init call.
Open Pycharm settings->Build,Execution,Deployment->Console->Django Console then
copy below into Starting script
from django_extensions.management.shells import import_objects
from django.core.management.color import no_style
globals().update(
import_objects({"dont_load": [], "quiet_load": False}, no_style())
)You will need:
Most of needed shortcuts can be called via invoke inv k8s.###. Just make sure that you log in with
inv k8s.login
k8s.logs
k8s.python-shell