The way to start a Django project with Docker and docker-compose
The way to start a Django project with Docker
Clone this git repository to your local machine.
Install docker
and docker-compose
using official documentation.
Add user to the docker group to run commands without sudo:
sudo usermod -aG docker $USER
Update settings in dev.env
and confetti/settings/prod.py
(recommended).
Go to the project root and run:
docker-compose up
docker-compose exec web python manage.py createsuperuser
docker-compose exec web python manage.py test
http://localhost:8000/
.Create and fill .env
and confetti/settings/prod.py
.
Run application:
docker-compose -f docker-compose.prod.yml up
Generate certificates(see next section).
Navigate to https://localhost/
.
How to generate ssl certificates? Follow this guide.
The simplest way with less headaches:
docker-compose -f docker-compose.prod.yml exec nginx sh
apk update && apk add certbot certbot-nginx
certbot certonly --nginx # follow instructions
deployment/nginx/app.conf
, and then:docker-compose -f docker-compose.prod.yml up --build
Ad Hoc docker/docker-compose commands (put in .bash_aliases):
alias dcubn=docker-compose build --no-cache
alias dcub=docker-compose up --build
alias dcu=docker-compose up
⭐️ Thanks everyone who has starred the project, it means a lot!
Happy coding :blush: