Skip to content

min0ru/django_tdd_docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tutorial Project: Test-Driven Development with Django, Django REST Framework and Docker

pipeline status coverage report

Development environment deployment

Requirements for dev environment

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)

Environment variables

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=*

Docker-Compose Dev Environment

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

Application

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/

Testing

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

Code Quality Control

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 .

Production Deployment

Automatic CI/CD available with provided GitLab CI config (.gitlab-ci.yml).

Check Django settings.py file for other configurable environment variables.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published