Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker will now force-remove rendition entries from db #216

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions bakerydemo/base/management/commands/delete_renditions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.core.management.base import BaseCommand
from django.db import connection

# Force removal of wagtail image rendition-entries in db will force wagtail to
# regenerate renditions. Useful if renditions are removed, for instance when
# using Docker where the file system is renewed on each build.

class Command(BaseCommand):
def handle(self, **options):
with connection.cursor() as cursor:
cursor.execute("SELECT count(*) FROM wagtailimages_rendition")
row=cursor.fetchone()
cursor.execute("DELETE FROM wagtailimages_rendition")
print("{} renditions removed".format(row[0]))
3 changes: 3 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ done

if [ "$1" = '/venv/bin/uwsgi' ]; then
/venv/bin/python manage.py migrate --noinput
# Since we are running docker, we need to delete rendition entries from db
# since the docker image will have a non-populated /media/image directory
/venv/bin/python manage.py delete_renditions
fi

if [ "x$DJANGO_LOAD_INITIAL_DATA" = 'xon' ]; then
Expand Down