Dockerizing Django with Postgres, Gunicorn, Nginx and Certbot
🚀
Features
A Django stater project with fully basic requirements for a production-ready version.
- Dockerizing Django with Postgres, Gunicorn, and Nginx. Refer: django-on-docker
- Configuration for Nginx and Certbot with Let’s Encrypt on docker-compose. Refer: nginx-certbot
- Django REST framework sample.
- A batteries-included, opinionated template for Django. Refer: djangox
- User log in/out, sign up, password reset via django-allauth
- Static files configured with Whitenoise
- Styling with Bootstrap v4
- Debugging with django-debug-toolbar
- DRY forms with django-crispy-forms
Development
Uses the default Django development server.
-
Rename .env.dev-sample to .env.dev.
-
Update the environment variables in the docker-compose.yml and .env.dev files.
-
Build the images and run the containers:
$ docker-compose up -d --build
Test it out at http://localhost:8000.
Production
Uses gunicorn + nginx.
-
Rename .env.prod-sample to .env.prod and .env.prod.db-sample to .env.prod.db. Update the environment variables.
-
Build the images and run the containers:
$ docker-compose -f docker-compose.prod.yml up -d --build
Test it out at http://localhost:1337.
-
Modify init-letsencrypt.sh & app.conf with domains and email addresses then running it:
$ ./init-letsencrypt.sh