Running Locally With Docker

This project relies heavily on Docker and Docker Compose.

Prerequisites

Build the App

This command should always be run when something changes either in Dockerfile or in app requirements:

docker-compose -f local.yml build

Run the App

At first build the frontend static files:

docker-compose -f web.yml up --build

Command will build the frontend container and use it to generate static files to /beverage_tasting/static. Django later collects and serves static files from this directory.

Next step is to actually run Django and PostgreSQL:

docker-compose -f local.yml up

It might be handy to always start services with build options. It is fast when cached and only takes longer when changes occurred. Following command is therefore recommended:

docker-compose -f local.yml up --build

Usually only local.yml file will be used with Docker Compose. You can set environment variable pointing to this file:

export COMPOSE_FILE=local.yml

Then you can run only:

docker-compose up --build

Executing Management Commands

Run one-off container to perform common Django commands:

docker-compose run --rm django python manage.py createsuperuser

Command will create container with only the Django application and destroy itself afterwards.

Environment Configuration

Configuration files for local environment are located in .envs/.local. Username and password for PostgreSQL in .envs/.local/.postgres might come handy when setting up remote access, e.g. for DBeaver.