Dockerize a Django App with Postgres and Redis
Devin writes a multi-stage Dockerfile, a docker-compose.yml with Django, PostgreSQL, and Redis, then builds and runs the stack to verify it works.(Optional) Scope the project with Ask Devin
If you’re not sure which services your Django app depends on or how the project is structured, use Ask Devin to investigate first:You can also start a Devin session directly from Ask Devin, and it will carry over everything it learned as context.
Give Devin your Django project and requirements
Point Devin at the Django project to containerize and mention anything specific — base image preferences, services the app depends on, or image size constraints. Devin reads your
requirements.txt or pyproject.toml to figure out the rest.Devin investigates and builds
Devin reads your Django project and dependency files to understand the build process, then creates the Docker configuration:
- Reads dependency files — Parses
requirements.txtorpyproject.toml, identifies Django, psycopg2, redis, celery, and gunicorn - Writes the Dockerfile — Creates a multi-stage build that installs dependencies in a builder stage and copies the virtual environment into a minimal
python:3.12-slimruntime image
- Writes docker-compose.yml — Adds Django, PostgreSQL, Redis, and a Celery worker with health checks, volumes, and a shared network
- Adds .dockerignore — Excludes files that don’t belong in the build context (
__pycache__,.git,tests/,docs/,*.pyc) - Runs
docker compose up --build— Builds the image and starts all services in Devin’s terminal - Verifies the app — Curls
/api/health/to confirm Django starts cleanly, connects to PostgreSQL, and reaches Redis
Guide the session with slash commands
Use slash commands during the session to steer Devin’s workflow:
/plan— Ask Devin to outline its approach before writing any Docker configuration. Review the plan and suggest changes./test— Tell Devin to rebuild and re-verify the container stack. Use this after each change to catch issues early./review— Ask Devin to review its own Dockerfile and compose config for security issues, image size, and best practices before opening the PR.
Review the PR with Devin Review
Once Devin opens the PR, use Devin Review to review the Docker configuration. Devin Review can catch security issues (running as root, exposed secrets), missing best practices (no
.dockerignore, no health checks), and inconsistencies with your existing infrastructure.