sudo apt install docker.io docker-compose
Optional requirements (for running application without dockerized environment)
pyenv (for installing different python versions)
pipenv (managing python virtual environments and packages)
Create .env.dev file with example development configuration:
POSTGRES_DB=movies_dev
POSTGRES_USER=movies
POSTGRES_PASSWORD=movies
SECRET_KEY=DEBUG_SECRET_KEY
DEBUG=1
DB_ENGINE=django.db.backends.postgresql
DB_NAME=movies_dev
DB_USER=movies
DB_PASSWORD=movies
DB_HOST=movies-db
DB_PORT=5432
DJANGO_ALLOWED_HOSTS=*
Build and run docker-compose environment:
docker-compose up --build -d
Check docker containers up and running:
docker-compose ps
Check containers logs:
docker-compose logs -f
Shut down development enironment:
docker-compose down -v
After running docker-compose environment application will be available with links provided:
Smoke test endpoint: http://localhost:8000/ping/
API endpoints: http://localhost:8000/api/
OpenAPI v2 documentation (swagger): http://localhost:8000/swagger/
CoreAPI documentation: http://localhost:8000/docs/
Run tests in dockerized environment:
docker-compose up --build -d
docker-compose exec movies pytest
Run tests with coverage report
docker-compose up --build -d
docker-compose exec movies pytest --cov
Run code quality checks:
docker-compose exec movies flake8 .
docker-compose exec movies black . --check
docker-compose exec movies isort . --check-only
Automatic formating and imports sorting:
docker-compose exec movies black .
docker-compose exec movies isort .
Automatic CI/CD available with provided GitLab CI config (.gitlab-ci.yml).
Check Django settings.py file for other configurable environment variables.