Skip to content

RomanMazyrin/Salaries-project

Repository files navigation

Application environment variables

  • SECRET_KEY - django SECRET_KEY from settings
  • DEBUG - 1 or 0. Debug mode in Django
  • DATABASE_URL - URL in the format of dj-database-url
  • RUN_MIGRATIONS - Flag to run migratioins or not. Set 1 to run migrations while container starting.
  • CREATE_SUPERUSER - Flag to create superuser or not. Set 1 to createsuperuser while container starting. Also must set another superuser environment variables, look next.
  • DJANGO_SUPERUSER_PASSWORD - superuser password. Need it and it is applied only when CREATE_SUPERUSER=1
  • DJANGO_SUPERUSER_USERNAME - superuser username. Need it and it is applied only when CREATE_SUPERUSER=1
  • DJANGO_SUPERUSER_EMAIL - superuser email. Need it and it is applied only when CREATE_SUPERUSER=1
  • AMOCRM_ENTITIES_ENDPOINT_AUTH_KEY - Auth key for third-party server requests for fetching amoCRM entities for salary calculating
  • SALARIES_DASHBOARD_AUTH_KEY - Auth key for access to salaries dashboard on application server on page https://{{hostname}}/salaries/sales-plan-progress?auth_key={{AUTH_KEY}}.

For docker environment variables look Docker section

Preparing before first launch on local machine

Install dependencies

$ poetry install

Activate virtual environment shell

$ poetry shell

Set environment variables


Create .env file in folder and set necessary values for env variables

Collect static and make migrations

$ poetry run python manage.py collectstatic --no-input
$ poetry run python manage.py migrate --no-input
$ poetry run python manage.py createsuperuser

Starting server

$ make runserver

Linting

$ make lint

Testing

$ make test

Testing with code coverage

$ make test-coverage

Docker run

Before run

Here is a docker-compose.yml config example, which is actually ready for local machine launch.

Before launch you need to do next. It's optional, but you should know about it:

Set env variables in docker-compose.yml (parameter environment), or create .env file in the root of project and fill it with actual env variables for docker containers. Don't forget about changing docker-compose.yml config for successfully apply .env file params (parameter env_file) for each service

Docker container environment variables

All application environment variables + below:

  • G_NUM_OF_WORKERS - Number of workers on Gunicorn
  • G_WORKER_TIMEOUT - Gunicorn worker request timeout
  • G_WORKER_CONNECTIONS - Number of connnections per one Gunicorn worker
  • G_PORT - Port listened by Gunicorn

Run

$ docker-compose up

Docker build

To rebuilding image to the last code version, you have to:

  1. Run docker-compose build command. Wait for rebuilding.
  2. docker-compose up again to up services with new images.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published