-
Notifications
You must be signed in to change notification settings - Fork 3
Install using docker
This is a Django stack on Docker with focus on simplicity. The GEN Django application is located in the app directory. Since it is mounted into the container, code changes will be automatically applied. All the customizable configuration variables are in the config directory.
If you don't have docker and docker-compose installed, follow these steps (for Ubuntu 20.04):
- https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04
- https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-20-04
To get GEN up and running, clone this repository and follow these steps:
- Copy and edit the environment settings file:
cp config/gen/example.env config/gen/.env- If MUST review and edit this file. It defines the secret key parameter, database settings, etc.
- Build and start GEN and NGINX:
docker-compose up -d --build - Run database migration:
docker-compose run gen python manage.py migrate - Collect static files to be served by NGINX:
docker-compose run gen python manage.py collectstatic --no-input -v 2
Wait for a few seconds for the services to be up and running. Then open the app at http://localhost (if running on a local machine) or at your domain.
Follow the same steps listed above, but make sure to verify these settings on the following files:
-
config/gen/.env: set DEBUG to False -
config/gen/.env: add domain name to ALLOWED_HOSTS -
config/nginx/conf.d/default: change server_name to your domain name
docker-compose downdocker-compose run gen /bin/sh -c "python manage.py flush; python manage.py migrate"
docker-compose run gen python manage.py createsuperuserdocker-compose logs nginx
docker-compose logs genRemove all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes.
docker system prune -f
docker system prune -f --volumesIf you need to access one of the docker images for some reason, you can use this command:
docker exec -it gen /bin/shTo access the nginx image, just replace gen with gen_nginx.
Before using in production, you have to carefully review docker environments configuration files and also GEN's settings.py file.
Refer code from testdriven.io, rowdybeaver and Docker official docs for details on the docker-compose production setup.
- This docker setup was based on arocks/django3-asgi-perf.
- Django management commands:
docker-compose run gen python manage.py _commandname_