CI/CD pipelines for Django in production
Automated test-and-deploy pipelines on GitHub Actions, GitLab, and Bitbucket, plus the images and previews they produce.
A pipeline runs the same steps for every change: test, build, deploy, and verify. It removes the memory-dependent parts of a manual release and leaves a record of what went where.
The guides cover GitHub Actions, GitLab CI, Bitbucket Pipelines, and preview environments, with secrets handled so that CI never holds more access than it needs.
Set it up
Guides that take this from nothing to running in production.
- Deploy Django with GitHub Actions CI/CD
Manual Django deployments usually fail in predictable ways: someone forgets to run migrations, static files are outdated, the wrong branch gets pushed to production, or a restar...
- Deploy Django with GitLab CI/CD
Build a GitLab CI/CD pipeline for Django: PostgreSQL tests, Docker image builds, SSH deploys with protected variables, and one-click rollbacks.
- Deploy Django with Bitbucket Pipelines
Build a Bitbucket Pipelines CI/CD workflow for Django: tests against a PostgreSQL service, cached dependencies, deployment environments, SSH deploys, and a manual production gate.
- Preview Environments for Django Pull Requests
Spin up a temporary Django environment for every pull request: GitHub Actions, Docker Compose on a preview host, wildcard subdomains, per-PR databases with seed data, and automatic teardown.
- Deploy Django Docker Images from GitHub Container Registry
Build Django images in GitHub Actions, push them to GHCR with immutable tags, pull them on servers with read-only credentials, deploy by tag or digest, and clean up old versions.
- Deploy Django With a Jenkins Pipeline
Build a Jenkins pipeline for Django: a declarative Jenkinsfile that runs tests against PostgreSQL in Docker, builds and pushes an image, deploys over SSH with migrations, uses credentials binding, and gates production behind approval.
- Deploy Django With CircleCI
Set up CircleCI for a Django project: a config.yml with a PostgreSQL service image, dependency caching, parallel test splitting, Docker image builds, and an SSH or registry-based deploy job gated by branch filters and approval.
- Deploy Django With Azure DevOps Pipelines
Build an Azure Pipelines YAML pipeline for Django: test with a PostgreSQL service container, publish an image to Azure Container Registry, deploy to App Service or a VM through environments with approvals, and keep secrets in variable groups or Key Vault.
- Test and Deploy Django With Buildkite
Build a Buildkite pipeline for Django: run tests with PostgreSQL on self-hosted agents using the Docker Compose plugin, build and push images, gate production deploys with block steps, run migrations, and keep secrets out of pipeline YAML.
- Test and Deploy Django With Woodpecker CI
Set up Woodpecker CI, a lightweight self-hosted CI engine, for Django: write .woodpecker.yaml pipelines with a PostgreSQL service, run tests and linting, build and push images with the buildx plugin, deploy over SSH on main, and manage secrets.
- Deploy Django to AWS From GitHub Actions With OIDC (No Access Keys)
Replace long-lived AWS access keys in GitHub Actions with OpenID Connect: create the GitHub OIDC provider and an IAM role with a trust policy scoped to your repo and branch, assume it with aws-actions/configure-aws-credentials, and push to ECR and deploy ECS.
- Test and Deploy Django With Gitea or Forgejo Actions
Use Gitea Actions or Forgejo Actions, GitHub Actions-compatible CI built into self-hosted forges, for Django: register act_runner, write workflows with a PostgreSQL service, push images to the built-in container registry, and deploy over SSH with secrets.
- Set Up a Staging Environment for Django
Build a Django staging environment that catches real release problems: production parity, isolated data and secrets, and safe side effects.
- Deploy Django with Argo CD (GitOps)
Deploy Django to Kubernetes with Argo CD: a config repository, an Application with automated sync, PreSync migration hooks, CI-driven image tag updates, and rollback by git revert.
- Build Multi-Architecture Django Docker Images
Build Django images for both amd64 and arm64 (Graviton, Ampere, Apple Silicon) with docker buildx: QEMU versus native runners, wheels, caching in GitHub Actions, and verifying manifests.
- Compile Django Translations During Deployment
Ship Django translations reliably: run compilemessages in CI or a Docker build stage with gettext, ignore virtualenvs, validate .po files, restart workers, and verify every language in production.
- Deploy Django With git push and a post-receive Hook
Deploy Django to your own server with git push production main: a bare repository with a post-receive hook that checks out the code, installs dependencies, runs migrations and collectstatic, and reloads Gunicorn, with safe failure handling.
- Build Django Images With Cloud Native Buildpacks
Build production Django container images without a Dockerfile using Cloud Native Buildpacks and the pack CLI: choose a builder, configure Python version and start command with a Procfile, run collectstatic, rebase images for OS patches, and use it in CI.
- Sign and Verify Django Docker Images With Cosign
Sign Django container images with Sigstore Cosign in CI using keyless signing through GitHub Actions OIDC, attach SBOM and provenance attestations, and verify signatures before deploy or with a Kubernetes admission policy.
Run it well
Tuning, reliability, and operations once it works.
- Manual vs Automated Django Deployment: When to Switch
Many Django teams start with a manual deployment process over SSH. That is normal: log into a Linux server, pull code, install dependencies, run migrations, collect static files...
- Speed Up Django Docker Builds With Layer and Cache Mounts
Make Django Docker builds fast in CI and locally: order layers so dependencies cache, BuildKit cache mounts for pip and uv, registry-backed cache for CI, .dockerignore, and multi-stage builds that compile once.
Check it
Review lists to run before launch or after a change.
- Django CI/CD Pipeline Checklist
A checklist for a Django CI/CD pipeline: tests on the production database engine, migration checks, linting and security scans, building one artefact, deploying migrations safely, smoke tests, approvals, rollback, and secrets handling.
Fix it
Errors and symptoms, each traced to a cause and a fix.
- Fix "Permission denied (publickey)" in Django CI Deploys
Fix Permission denied (publickey) and Host key verification failed when GitHub Actions, GitLab CI, or another pipeline deploys Django over SSH: load the private key correctly, add known_hosts, fix authorized_keys permissions, and check the user.
- Fix Django Tests That Pass Locally but Fail in CI
Fix Django test suites that pass on your machine but fail in GitHub Actions or GitLab CI: PostgreSQL service containers and health checks, missing settings and secrets, static files manifest errors, time zones, and test ordering.
- Fix "fatal: detected dubious ownership in repository" When Deploying Django
Fix git fatal detected dubious ownership in repository during Django deploys, CI jobs, and Docker builds: understand the safe.directory check, run git as the repository owner, fix ownership, or add a narrow safe.directory entry.
- Fix "Host Key Verification Failed" in GitHub Actions Django Deploys
Fix Host key verification failed when a GitHub Actions workflow deploys Django over SSH: add the server’s host key to known_hosts from a secret, avoid StrictHostKeyChecking=no, handle rebuilt servers and custom ports, and verify fingerprints.
- Fix Kubernetes ImagePullBackOff for a Django Deployment
Fix Kubernetes ImagePullBackOff and ErrImagePull for Django pods: read the pull error, fix image names and tags, add imagePullSecrets for GHCR, ECR, or GitLab, handle expiring ECR tokens and rate limits, and match image architecture to nodes.
Learning paths through this topic
- Docker, from image to productionBuild a production image, run it with Compose, ship it from CI, and check the result.
- Releases without downtimeScript the release, make migrations backward compatible, and switch, verify, or roll back without users noticing.
- Django on KubernetesRun Django on a cluster with config, ingress, probes, jobs, graceful shutdown, and autoscaling, then package it with Helm and GitOps.