Skip to content

A Django-Postgres-uWSGI-NGINX Docker Container including the local and production development configurations

Notifications You must be signed in to change notification settings

jryantz/django-docker

Repository files navigation

Docker (Django - Postgres - uWSGI - NGINX)

How to Use

  1. Clone repository
  2. Create an environment file (rename .env.example to .env to get started)
    1. Generate and update SECRET_KEY
      from django.core.management import utils
      print(utils.get_random_secret_key())
    2. Add site URLs to ALLOWED_HOSTS
    3. Configure the DB parameters
  3. Run
    • Local Development
      • docker compose up
    • Production
      • docker compose -f docker-compose-deploy.yml up
    • --build
      • Builds the image before starting the container
  4. Run Commands
    • Local Development
      • docker compose run app python manage.py <command>
    • Production
      • docker compose -f docker-compose-deploy.yml run app python manage.py <command>
    • <command>:
      • makemigrations
      • migrate

Repeat Instructions

Follow these instructions to recreate the Docker container from scratch.

Setup Python

  1. Install Python

Setup Django/uWSGI

  1. Create Dockerfile and add configuration
  2. Create scripts folder
  3. Create scripts/run.sh and add configuration
  4. Create docker-compose.yml and add configuration
  5. Test, run docker compose up

Setup NGINX

  1. Create proxy folder
  2. Create proxy/default.conf.tpl and add configuration
  3. Create proxy/uwsgi_params and copy configuration from https://uwsgi-docs.readthedocs.io/en/latest/Nginx.html#what-is-the-uwsgi-params-file
  4. Create proxy/Dockerfile and add configuration
  5. Create proxy/run.sh and add configuration

Customize Configuration

  1. Configure SECRET_KEY and DEBUG to use envrionment variables
  2. Configure STATIC_URL, MEDIA_URL, STATIC_ROOT, and MEDIA_ROOT to point to the correct folders

Production Deployment Setup

  1. Create docker-compose-deploy.yml and add configuration

About

A Django-Postgres-uWSGI-NGINX Docker Container including the local and production development configurations

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published