Skip to content

Latest commit

 

History

History
68 lines (57 loc) · 3.39 KB

docker.md

File metadata and controls

68 lines (57 loc) · 3.39 KB

Docker - Documentation - Django Event Management

Eventslite - Simple container using SQlite

  • Note: This will copy the files of the current directory, including the currently used SQLite database. Maybe you want to clean up your code first.
  • Build an image from the Dockerfile-SQLite (also copies files). It installs requirements_dev.txt, copies files and runs migrate:
    podman build --tag eventslite --file Docker/Dockerfile-SQLite ./
  • Create and run a new container from the image:
    podman run --name eventslite --detach --interactive --tty --publish 8000:8000 eventslite
  • Import example data:
    podman exec eventslite python manage.py loaddata events/fixtures/examples/0001_user.xml events/fixtures/examples/0002_person.xml events/fixtures/examples/0003_event.xml events/fixtures/examples/0004_registration.xml
  • Start server in interactive bash:
    podman exec --interactive --tty eventslite bash
    • python manage.py runserver 0.0.0.0:8000
  • Stop server in interactive bash:
    • Press [ctrl]+[c] and type exit
  • Stop the container:
    podman stop eventslite

Compose - Container using Postgres

  • Create and start containers from the Dockerfile. It installs requirements_prod.txt, copies files and runs migrate:
    podman-compose --file Docker/docker-compose.yml --project-name events up --detach
  • Passwords for the database and superuser are set via environment variables in docker-compose.yml.
  • To stop and remove containers, use down
  • To (re-) build services, use build

Commands

Python settings

# Ensure Python output is logged to the terminal, making it possible to monitor Django logs in realtime 
# https://www.nileshdalvi.com/blog/dockerize-django-app/
#
# Force the stdout and stderr streams to be unbuffered
# https://docs.python.org/3/using/cmdline.html#envvar-PYTHONUNBUFFERED
ENV PYTHONUNBUFFERED 1

Postgres image