Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
-v <volume name>:<path to mount>

It is recommended that the entrypoint.sh script is used to establish the database connection. The general sequence in the entrypoint.sh script to connect the database on the volume is:

  • Run makemigrations/ migrate. This creates a db.sqlite3 database file in its default location in the project root folder.

  • Delete the db.sqlite3 file from the project root folder.

  • Create a symlink to the database folder.

Here is an example of an entrypoint.sh script:

Code Block
#!/bin/bash

# Ensure the log directory exists
mkdir -p /var/log/django

# Redirect stdout and stderr to the log file
exec >> /var/log/django/entrypoint.log 2>&1

python3 manage.py makemigrations
python3 manage.py migrate

rm /opt/ece_li_scheduling/db.sqlite3
ln -s /var/lib/ece_li_scheduling/db.sqlite3 /opt/ece_li_scheduling/db.sqlite3

python3 manage.py runserver 0.0.0.0:8000

Start First App

  • Navigate to the root directory of the Django project (where the manage.py file is located).

  • Use manage.py to initialize the app:

    Code Block
    python3 manage.py startapp <app name>

...