Docker Compose configuration for Django development (and production) with Nginx, Celery, Redis and PostgreSQL
A boilerplate to deploy Django with cool stuff. Also serves as an example project from these tutorials:
- Deploy Django, Gunicorn, NGINX, Postgresql using Docker
- Serve Static Files by Nginx from Django using Docker
- Docker: Use Celery in Django (Redis as Broker)
The above tutorials describe how this boilerplate was created from scratch so that you can build your own.
- Fork the repo to your GitHub account.
git clone
the repo to your local computer.- Run
make build
inside the root directory to build/rebuild (if necessary) all the containers in the project. - Then run
make up
to start the containers and have them run as a daemon process (i.e., in the background). - Visit
http://localhost:8000/
to see the project. - Visit
http://localhost:8000/admin
to view the admin login screen. No users have been setup, so you won't be able to login until after you have done that.
Checkout the commands section below for more usage.
A default Django project resides in src
directory. When you start the project, you will see the following screen at http://localhost:8000/
:
Also when you access the django container log via make log-web
, you will see the following:
The following commands can be run inside the project root directory (see the Makefile in this project for more details):
make build
to build/rebuild (if necessary) all the containers in the project.make up
to start the containers and have them run as a daemon process (i.e., in the background).make up-non-daemon
to start containers and have them run as a non-daemon process.make start
to start containers, if the project has already been built.make stop
to stop containers.make restart
to restart containers.make shell-web
to gain shell access into the web container.make shell-db
to gain shell access into the db container.make shell-nginx
to gain shell access into the nginx container.make log-web
to view the logs in the web container.make log-db
to view the logs in the db container.make log-nginx
to view the logs in the nginx container.make collectstatic
to put static files in the static directory.