Skip to content

Your all-in-one Django-Docker starter kit. Pre-configured services including PostgreSQL, Redis, Celery, with Nginx for production. Streamlined development with included tools for testing and formatting.

License

Notifications You must be signed in to change notification settings

TheCodingSheikh/django-docker

 
 

Repository files navigation

Django Docker Quickstart

This quickstart provides an easy way to initiate a Django project using Docker. It comes with pre-configured services including PostgreSQL, Redis, Celery (worker and beat) and Nginx, ready to run a Django web application. Additionally, it provides a few handy shortcuts for easier development.


Features 🚀

  • Django web application framework
  • PostgreSQL database
  • Redis in-memory data structure store
  • Celery worker and beat services for running background tasks asynchronously
  • Nginx web server for serving static and media files, and proxying requests to the Django application

Included Packages and Tools 🛠️

  • Pytest: Testing framework
  • Pytest Sugar: A pytest plugin for a better look
  • Pytest Django: A pytest plugin providing useful tools for testing Django applications
  • Coverage: Test coverage tool
  • Ruff: Linter
  • Black: Code formatter

Requirements 📋


Getting Started 🏁

  1. Clone the repository:

    git clone https://github.com/TheCodingSheikh/django-docker.git
  2. Change directory into the project:

    cd django-docker
  3. Copy the env.example file to .env and update the values as needed:

    • For Linux/macOS:
      cp env.example .env
    • For Windows (Command Prompt):
       Copy-Item -Path env.example -Destination .env
  4. Find and replace all project_name and rename the folder under src to your like


Initial Setup ⚙️

Development Prerequisites

  1. Build the image and run the container:

    • If buildkit is not enabled, enable it and build the image:

      DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose -f docker-compose.yml up --build -d
    • If buildkit is enabled, build the image:

      docker-compose -f docker-compose.yml up --build -d
    • Or, use the shortcut:

      make build-dev

You can now access the application at http://localhost:8000. The development environment allows for immediate reflection of code changes.

Production Setup

  1. Build the image and run the container:

    • If buildkit is not enabled, enable it and build the image:

        DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose -f docker-compose.prod.yml up --build -d
    • If buildkit is enabled, build the image:

       docker-compose -f docker-compose.prod.yml up --build -d
    • Or, use the shortcut:

        make build-prod

Shortcuts 🔑

This project includes several shortcuts to streamline the development process:

  • Create migrations:

    make make-migrations
  • Run migrations:

    make migrate
  • Run the linter:

    make lint
  • Run the formatter:

    make format
  • Run the tests:

    make test
  • Create a super user:

    make super-user
  • Build and run dev environment:

    make build-dev
  • Build and run prod environment:

    make build-prod

About

Your all-in-one Django-Docker starter kit. Pre-configured services including PostgreSQL, Redis, Celery, with Nginx for production. Streamlined development with included tools for testing and formatting.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 54.6%
  • Shell 33.8%
  • Makefile 8.5%
  • Dockerfile 3.1%