DEV Community

Cover image for Django, Hot Reload in Docker (VIDEO)

Posted on • Originally published at

Django, Hot Reload in Docker (VIDEO)

Hello Coders!

The video mentioned in this article presents Django Corporate an open-source starter enhanced with HOT Reload when running in Docker. This is useful for those that prefer to write the code in isolated environments like Docker and see the changes without restarting the instance (source code saved on GitHub). Thanks for reading!

This enhancement was possible based on the following changes made to the Docker scripts:

✅ Define the codebase as a volume in docker-compose.yml

version: "3.8"
    container_name: appseed_app
    restart: always   <-- NEW (For HOT reload)
    build: .
      - ./:/app       <-- NEW (For HOT reload)
      - db_network
      - web_network
Enter fullscreen mode Exit fullscreen mode

✅ Force Gunicorn reload in

set -e

# Function to start Gunicorn with dynamic reload-extra-file options
start_gunicorn() {
    # Generate the reload-extra-file options dynamically
    extra_files=$(find /app/templates -name "*.html" -printf "--reload-extra-file %p ")

    # Start Gunicorn
    echo "Starting Gunicorn..."
    gunicorn --config --reload --reload-engine=poll $extra_files core.wsgi

# Start Gunicorn
Enter fullscreen mode Exit fullscreen mode

The above changes combined will trigger a HOT Reload in Docker if we change the Python code or the template files. The demonstration of this feature can be visualized in this short YoutTube material:

Thanks for reading! For more resources, feel free to access:

👉 More ui themes and templates - free & paid products
👉 Admin Dashboards - a huge index with templates and apps

Top comments (0)