Basic setup¶
In order to recreate the structure of .envs directory that the project uses, start with creating the .envs directory in the root of the project, as it is done below.
pomodorr
├── .envs
│ ├── .local
│ ├── .django
│ ├── .postgres
│ └── .production
│ ├── .django
│ ├── .postgres
Configure environment variables¶
The configurations listed below resemble the default environment setting files needed to set the project up:
- local envs:
pomodorr/.envs/.local/.django
- # GeneralUSE_DOCKER=yesIPYTHONDIR=/app/.ipythonDJANGO_SETTINGS_MODULE=config.settings.local# RedisREDIS_URL=redis://redis:6379/0# Celery / FlowerCELERY_FLOWER_USER=<your_celery_flower_user>CELERY_FLOWER_PASSWORD=<your_celery_flower_password>
pomodorr/.envs/.local/.postgres
- # PostgreSQLPOSTGRES_HOST=postgresPOSTGRES_PORT=5432POSTGRES_DB=pomodorrPOSTGRES_USER=<your_postgres_user>POSTGRES_PASSWORD=<your_postgres_password>
- production envs:
pomodorr/.envs/.production/.django
- # General# DJANGO_READ_DOT_ENV_FILE=TrueDJANGO_SETTINGS_MODULE=config.settings.productionDJANGO_SECRET_KEY=<your_secret_key>DJANGO_ADMIN_URL=<your_admin_url>DJANGO_ALLOWED_HOSTS=<your_hosting_domain># Security# TIP: better off using DNS, however, redirect is OK tooDJANGO_SECURE_SSL_REDIRECT=False# EmailMAILGUN_API_KEY=<your_mailgun_api_key>DJANGO_SERVER_EMAIL=<your_server_email>MAILGUN_DOMAIN=<your_mailgun_domain># AWSDJANGO_AWS_ACCESS_KEY_ID=<your_aws_access_key_id>DJANGO_AWS_SECRET_ACCESS_KEY=<your_aws_secret_access_key>DJANGO_AWS_STORAGE_BUCKET_NAME=<your_aws_storage_bucket_name># GunicornWEB_CONCURRENCY=4# SentrySENTRY_DSN=<your_sentry_dsn># RedisREDIS_URL=redis://redis:6379/0# Celery / FlowerCELERY_FLOWER_USER=<your_celery_flower_user>CELERY_FLOWER_PASSWORD=<your_celery_flower_password>
pomodorr/.envs/.production/.postgres
- # PostgreSQLPOSTGRES_HOST=postgresPOSTGRES_PORT=5432POSTGRES_DB=pomodorrPOSTGRES_USER=<your_postgres_user>POSTGRES_PASSWORD=<your_postgres_password>
Building and running containers¶
The details about getting the project up and running is described on the official django-cookiecutter documentation.
Having configured the environment variables all there is left to do is to build the docker containers and run them. Assuming your current directory is the root directory of the project, type:
$ docker-compose -f local.yml build
The last step is to get the containers up.
$ docker-compose -f local.yml up
Note
pomodorr/local.yml
configuration file and change the clashing ports.Building documentation with sphinx and sphinx-apidoc¶
Assuming your current directory is pomodorr/docs
, in order to generate the apidoc out of your docstrings, execute:
$ sh apidoc.sh
Having done that, in order to generate the html pages, type:
$ make html
API documentation¶
If application is run in DEBUG mode, there is available interactive swagger and redoc API documentation - by default under http://127.0.0.1:8000/swagger/ and http://127.0.0.1:8000/redoc/