Overview
The docker-django-react project is a local development template that combines Django as the backend framework, React as the frontend framework, and NGINX as the server. The project aims to provide an opinionated full-stack setup for developers using Docker-compose. It includes features like hot reload, Django Rest Framework, Docker containers, and support for serving static and media files with NGINX.
Features
- Django v5 as the backend framework
- Django Rest Framework for API development
- Django Rest Framework Simple JWT for authentication
- PyTest for testing the Django app
- Create React App for bootstrapping the React frontend
- Node development server via Docker LTS Alpine image
- Hot reload for efficient development
- Postgres database with Docker v16.1 Alpine image
- NGINX for serving static and media files and handling CORS issues
Installation
To use the docker-django-react project as a project template, follow these steps:
- Create a new repository on GitHub without a ReadMe file.
- On your local development machine, navigate to your preferred parent directory.
- Edit and rename the
.env-examplefile. All services expect to read environment variables from the.env.devfile. Review the example file and change the name to.env.dev. Make sure your.gitignorefile handles environment files to avoid committing sensitive information to a public repository. - Build the containers by running the following command:Add the
docker-compose build-upflag to bring services up after the build. - Bring the containers up by running the following command:Add the
docker-compose up -d-dflag to run the containers in detached mode. - Bring the containers down by running the following command:Add the
docker-compose down -v-vflag to also delete named volumes. - To view logs for a specific service, use the following command:
docker-compose logs <service-name> - To enter the shell of a specific container, use the following command (the container must be running):
docker exec -it <container-name> sh
Summary
The docker-django-react project is a local development template that combines Django, React, and NGINX using Docker-compose. It provides a convenient setup for full-stack development, with features like hot reload, Django Rest Framework, and Docker containers. By using NGINX for handling requests and serving files, the template also addresses CORS issues.