Skip to content

MobileAir/Dockerized_Django_RestFramework_Template-with_PostgreSql

Repository files navigation

Docker - Django Swagger template with PostgreSql, Redis, Ngnix

Features:

  • Docker/Docker-compose environment
  • Environment variables
  • Separated settings for Dev and Prod django version
  • Docker configuration for nginx for 80 and/or 443 ports (dev/stage/prod)
  • Let's Encrypt certbot
  • Celery worker
  • Redis service for caching using socket. Also message broker for queue
  • RabbitMQ configuration
  • ASGI support
  • Flake8 integration
  • Swagger in Django Admin Panel
  • Ready for deploy by one click
  • Separated configuration for dev and prod - requirements and settings
  • GitHub Actions
  • Redefined default User model in main.models.py
  • MailHog, Jaeger, RabbitMQ integrations
  • Multi-stage build for prod versions
  • PostgreSql Backup

Before running add your superuser email/password and project name in docker/prod/env/.data.env file

SUPERUSER_EMAIL=example@email.com
SUPERUSER_PASSWORD=secretp@ssword
MICROSERVICE_TITLE=MyProject

Run the local develop server:

docker-compose up -d --build
docker-compose logs -f

Server will bind to port 8000

Configuration for develop stage at 9000 port:

docker-compose -f prod.yml -f prod.dev.yml up -d --build

The same configuration could be for stage and prod:

docker-compose -f prod.yml -f prod.stage.yml up -d --build
docker-compose -f prod.yml -f prod.prod.yml up -d --build

For testing mail backend:

Set SMTP mail backend in settings

* Optional* Use MailHog service

docker-compose -f docker-compose -f docker/modules/mailhog.yml up -d --build
docker-compose -f prod.yml -f prod.dev.yml -f docker/modules/mailhog.yml up -d --build

For set https connection you should have a domain name

In prod.certbot.yml:

Change the envs: CERTBOT_EMAIL: your real email ENVSUBST_VARS: list of variables which set in nginx.conf files APP: value of the variable from list ENVSUBST_VARS

To set https for 2 and more nginx servers:

ENVSUBST_VARS: API UI
API: api.domain.com
UI: domain.com

Run command:

docker-compose -f prod.yml -f prod.certbot.yml up -d --build

About

Docker Template with Django Swagger, PostgreSql, Redis, Ngnix

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published