A simple devops-inspired template for Django applications setup with compose.
If you need a quick start with Django and Compose, you're in the right place. DjangOps is a dev-ops-inspired template for perfectionists with deadlines, who also happen to love Django and compose! Spin up a local dev environment with modular custom settings in a few steps and focus on the value you want to build. All comments, feedback, and contributions are highly encouraged. I always love to hear and learn from the community❤
Learn more about the Django framework from the official documentation.
This is an overview of the minimal setup needed to get started.
- Git
- Docker
- Docker Compose
- Docker Desktop
- IDE/Code/Text editor (PyCharm, VScode, Vim, etc)
Follow these tutorials to set up Docker and Compose on either Mac
or Linux.
I'd recommend Microsoft's documentation to set up Docker on WSL2 if you're on Windows.
The following setup was run on Ubuntu focal (20.04.6 LTS)
You can clone this repo with the following command.
- Clone repository
# cd your/desired/target/dir
$ git clone git@github.com:apexDev37/DjangOps.git my-project
$ cd my-project
This will clone the repository to a target dir on your host machine with a custom name
my-project/
and navigate into its root dir.
Before running your application with Compose, configure your
environment variables in the ./.envs/
directory. Example env
files are provided
to configure the following instances: Django and Postgres.
You can create the required env
files with the following code snippet.
- Create env files
# ensure you're in the project's root
$ for file in .envs/*.example; do cp "$file" "${file%.example}"; done
$ cd .envs/
This will loop through all the files in the .envs/ directory that end with .example and creates new files without the
.example
extension (ie.django.env.example
->django.env
).
⚠ After theenv
files are created, replace the placeholders with your own config values for your Django and Postgres instances.
You're all set to run your Django application. Spin up your Django and Postgres instances with the following command.
- Spin up containers
# ensure you're in the project's root
$ docker compose down
$ docker compose up -d
This will create and start the Django and Postgres instances in the same network defined in the
compose
file.
Once the containers have been created and started, you can access the application at http://localhost:8000
To make a repository open source, you must license it so that others may freely use, modify, and distribute the software. Using the MIT license, this project ensures this. The full original text version of the license may be seen here. To apply the right to your repository, follow the procedures.