Ready to Start Learning?

Sign in to check if you already have access, or get started with a purchase or membership.

Django Deployment Pipeline

This series is all about sustainably deploying Django into production on virtual machines we control. Production can get rather messy so we're going to limit the amount of manual work and opt for as much automation work as possible. To do this, we're going to be focusing on these core areas:
  • CI / CD with Git, GitHub, and GitHub Actions
  • Django on Docker & DockerHub (as well as using WatchTower)
  • Load Balancing with NGINX
  • Production Databases with managed MySQL by Linode
  • Local/Development use of production-like Databases
  • Terraform to provision Infrastructure on Linode
  • Ansible to configure infrastructure on Linode (in tandem with Terraform)
  • Django-based File Uploads & Django Static Files on Linode Object Storage
This course focuses on getting Django into production, but most of what we cover can be adapted for many other technologies as well. The reason? Our Django project will run through Docker with Docker containers. Docker is a massive key to putting many, many different applications in production. It's a great tool, and we'll use it as the backbone that Django sits on.
Before all the branded names for the tech stack start to scare you off, I want you to remember that so much of what we'll do here is writing a bunch of documents with a specific syntax and goal. Just because it's called Docker or Python or Terraform, they are still all just documents that describe... something.
With that in mind, I want you to think of the above list like this:
  • GitHub: a place to store our code, almost like a folder on your computer.
  • GitHub Actions: an app that automatically starts a chain of events related to testing (verifying the document does what the writer intended), building (let's put a stamp on this code and say that this version is done), and running our code in production (find the code that should run the best, is ready, and let's and run that)
  • Django: A bunch of python documents to handle the logic of an HTML website, store data, and handle user data.
  • Docker: essentially a document that we write to describe, on the operating system level, how our Django app needs to run. Docker itself does more than this, but we mostly work on the document part (a Dockerfile).
  • Load Balancing with NGINX: a document that we write to tell nginx to send incoming website traffic to the different servers running our Docker-based Django app. Managed databases: a powerful spreadsheet that you never need to open or touch (thanks to Linode & Django).
  • Terraform: a document describing all of the products and services we need from Linode (like virtual machines) to run our Django project.
  • Ansible: a few documents we use to tell all of the products and services what software our Django project needs is needed to run.
  • Linode Object Storage: a file system (sort of) that allows us to store files that don't change very often like images and videos as well as other documents like CSS and some kinds of JavaScript.
If you read the above and thought to yourself, "well that's overly simplistic" -- you're right! If you read the above and thought to yourself, "oh no, what am I doing with my life" -- you're right!
The nice thing about what we're doing here is taking the guesswork out of making this list work, work correctly, and work reliably. Most of the technology we will cover here has been well established and will likely remain unchanged for the foreseeable future.

References

Django Deployment Pipeline

Lifetime access to this course

or get access to 500+ courses with a membership

Lessons

1

Welcome

1:30

2

Configure Early, Deploy Often

4:36

3

Rapid Project Setup

4:04

4

In Depth Project Setup

22:25

5

Git Github & GitHub Actions

27:18

6

GitHub Actions Workflow Pipeline

7:53

7

GitHub Actions for Django & MySQL

7:04

8

Install MySQL Client

0:43

9

Containerize Django with Docker

8:11

10

Your First Dockerfile

12:07

11

Build Docker Container

12:58

12

Production-Ready Docker Container

10:18

13

Docker Compose for MySQL & Dev Env

16:40

14

Provision Production-Grade Managed Dev Database - Part 1

8:43

15

Provision Production-Grade Managed Dev Database - Part 2

7:31

16

Provision Production-Grade Managed Dev Database - Part 3

14:59

17

Github Action to Configure MySQL Database -Part 1

18:13

18

Github Action to Configure MySQL Database -Part 2

8:59

19

Push Docker Container to Docker Hub

14:13

20

Django Collect Static Automation Workflow

14:57

21

Install & Inialize Terraform

14:10

22

Linode Personal Access Token

3:07

23

Generate New SSH Keys & A Root User Password

7:49

24

Main Terraform File

7:59

25

Terraform Variables

5:37

26

Provision Instances

13:42

27

Terraform Github Actions Automation

15:18

28

Terraform Output Values

7:23

29

Terraform Template for Ansible Inventory

15:20

30

First Steps with Ansible

18:27

31

Ansible Role to Install Docker & Docker Compose

21:00

32

Destroy & Rebuild Infrastructure

6:14

33

GitHub Actions for Ansible

12:42

34

Ansible Templates

11:48

35

Nginx Load Balancer Ansible Role

9:19

36

Ansible Variables

5:40

37

Docker-Based Django App via Ansible

22:23

38

Ansible Local Testing

22:50

39

Solving FIrst Deployment Issues

25:13

40

Deploy Often

8:50

41

Thank you and a final challenge

1:11