this project is base on famous Django cookiecutter with some modifications (deleting Ruff and replacing black and extra)
- best python documenter
- see and search as you want in /search.html or py-modindex.html
- alive on local port 9500
- one of the most useful self hosted object storages
- python code
- alive on production and local port 9000
- as cache server
- alive on production and local
- as celery broker
- alive on production and local port 5672
- as celery inspector (you can make .env for it)
- alive on port 5555
- local email server (it is a very cool project)
- alive on production and local port 8025
- our lovely db
- also we have two postgres backup service (running in docker-compose)
- alive on production and local
- we have swagger/Redoc for api documentation in path /swagger, /redoc, swagger/?format=openapi (they actually work you can try yourself !)
- a cool admin in local /admin (and for production just use .env)
- pytest
- doc-test
- alive on port 8000
- open source reverse proxy and ingress controller
- you can easily make this project production ready
- alive on production it opens (flower 5555, port 80 and port 443)
- open source reverse proxy and ingress controller
- we use for images to avoid any security issue
-
first we can install python packages (use pyenv for better and easier response)
# install pyenv for your operating system pyenv install 3.11.9 pyenv virtualenv 3.11.9 jira pyenv local jira pyenv shell jira pip install --upgrade pip pip install -r requirements/local.txt
-
and second install pre-commit (a tool for check your code with black , flake8, mypy, isort and ... before commit and test code before push)
pip install pre-commit pre-commit install --hook-type pre-commit --hook-type pre-push
-
To Simple Build
docker-compose -f local.yml up
-
To Build and Run
docker-compose -f local.yml up --build
-
To Build and Run in Background
docker-compose -f local.yml up --build -d
-
To Make Migration, use this command:
docker-compose -f local.yml run --rm django python manage.py makemigrations
-
To Migration, use this command:
docker-compose -f local.yml run --rm django python manage.py migrate
-
To run tests:
docker-compose -f local.yml run --rm django pytest
-
To run tests with coverage
docker-compose -f local.yml run --rm django coverage run -m pytest docker-compose -f local.yml run --rm django coverage html docker-compose -f local.yml run --rm django open htmlcov/index.html
-
To Running type checks with mypy:
docker-compose -f local.yml run --rm django mypy jira
-
To create a superuser account, use this command:
docker-compose -f local.yml run --rm django python manage.py createsuperuser
-
set traefik url base on your domain to make set ssl automatic
-
create .envs/.production folder and put .envs like local there (you can use merge_production_dotenvs_in_dotenv.py)
-
You will need to build the stack first. To do that, run:
docker-compose -f production.yml build
-
Once this is ready, you can run it with:
docker-compose -f production.yml up
-
To run the stack and detach the containers, run:
docker-compose -f production.yml up -d
-
To run a migration, open up a second terminal and run:
docker-compose -f production.yml run --rm django python manage.py migrate
-
To create a superuser, run:
docker-compose -f production.yml run --rm django python manage.py createsuperuser
-
If you need a shell, run:
docker-compose -f production.yml run --rm django python manage.py shell
-
To check the logs out, run:
docker-compose -f production.yml logs
-
If you want to scale your application, run(don’t try to scale postgres, celerybeat, or traefik.):
docker-compose -f production.yml up --scale django=4 docker-compose -f production.yml up --scale celeryworker=2
-
Once you are ready with your initial setup, you want to make sure that your application is run by a process manager to survive reboots and auto restarts in case of an error. You can use the process manager you are most familiar with. All it needs to do is to run docker compose -f production.yml up in your projects root directory. (Supervisor config)
[program:{{cookiecutter.project_slug}}] command=docker compose -f production.yml up directory=/path/to/{{cookiecutter.project_slug}} redirect_stderr=true autostart=true autorestart=true priority=10
-
Move it to /etc/supervisor/conf.d/{{project_slug}}.conf and run:
supervisorctl reread supervisorctl update supervisorctl start {{project_slug}}
-
For status check, run:
supervisorctl status