Skip to content

Install using docker

Andrei Bosco B. Torres edited this page Jan 19, 2021 · 7 revisions

=== WORK IN PROGRESS ===

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.

Quick Start

If you don't have docker and docker-compose installed, follow these steps (for 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.

Deployment

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

Common Tasks

Shutting Down

docker-compose down

Load Initial Data

docker-compose run gen /bin/sh -c "python manage.py flush; python manage.py migrate"
docker-compose run gen python manage.py createsuperuser

View Error Logs

docker-compose logs nginx
docker-compose logs gen

Cleanup

Remove all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes.

docker system prune -f
docker system prune -f --volumes

Access docker image

If you need to access one of the docker images for some reason, you can use this command:

docker exec -it gen /bin/sh

To access the nginx image, just replace gen with gen_nginx.

Production

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.

References

Development

  • Django management commands: docker-compose run gen python manage.py _commandname_

Clone this wiki locally