wagtail/bakerydemo

Python version outdated in Dockerfile

fabienheureux opened this issue · 3 comments

Following #317, I noticed that python versions were outdated in the Dockerfile.

I can't test locally right now but I think this won't work since e94bfbb as django 4.0 only supports python 3.8 and higher.

I will submit a PR later this week when I can test this locally if it is not fixed by someone else before :)

Work in progress: gasman@9b62f42

Current issue is that it's failing on the update_index step that I added to the load_initial_data management command as part of the 2.16 upgrade (because the new database backend requires it) - the Docker image uses Elasticsearch as the search backend, and I suspect that's been broken for a while. We should probably just ditch Elasticsearch and use the database backend under Docker too.

Pomax commented

I tried updating the docker file to 3.9-slim with postgres 13.2 and while building the image itself works fine, loading the intial data crashes on:

Postgres is up - continuing
/venv/lib/python3.9/site-packages/dotenv.py:56: UserWarning: Not reading /code/.env - it doesn't exist.
  warnings.warn("Not reading {0} - it doesn't exist.".format(dotenv))
Traceback (most recent call last):
  File "/code/manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line
    utility.execute()
  File "/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/venv/lib/python3.9/site-packages/django/core/management/base.py", line 373, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/venv/lib/python3.9/site-packages/django/core/management/base.py", line 412, in execute
    self.check()
  File "/venv/lib/python3.9/site-packages/django/core/management/base.py", line 438, in check
    all_issues = checks.run_checks(
  File "/venv/lib/python3.9/site-packages/django/core/checks/registry.py", line 77, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/venv/lib/python3.9/site-packages/django/core/checks/caches.py", line 63, in check_file_based_cache_is_absolute
    cache = caches[alias]
  File "/venv/lib/python3.9/site-packages/django/utils/connection.py", line 62, in __getitem__
    conn = self.create_connection(alias)
  File "/venv/lib/python3.9/site-packages/django/core/cache/__init__.py", line 44, in create_connection
    return backend_cls(location, params)
  File "/venv/lib/python3.9/site-packages/django_redis/cache.py", line 51, in __init__
    self._client_cls = import_string(self._client_cls)
  File "/venv/lib/python3.9/site-packages/django/utils/module_loading.py", line 30, in import_string
    return cached_import(module_path, class_name)
  File "/venv/lib/python3.9/site-packages/django/utils/module_loading.py", line 15, in cached_import
    import_module(module_path)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/venv/lib/python3.9/site-packages/django_redis/client/__init__.py", line 1, in <module>
    from .default import DefaultClient
  File "/venv/lib/python3.9/site-packages/django_redis/client/default.py", line 9, in <module>
    from django.utils.encoding import smart_text
ImportError: cannot import name 'smart_text' from 'django.utils.encoding' (/venv/lib/python3.9/site-packages/django/utils/encoding.py)

Which makes sense, django 4.x removed support for smart_text (https://docs.djangoproject.com/en/4.0/releases/4.0/#features-removed-in-4-0) so it looks like the redis client is too old here, too.

Pomax commented

With django-redis updated to 5.2.0, we get a bit further but the load command still errors out, this time on missing wagtail tables:

Postgres is up - continuing
/venv/lib/python3.9/site-packages/dotenv.py:56: UserWarning: Not reading /code/.env - it doesn't exist.
  warnings.warn("Not reading {0} - it doesn't exist.".format(dotenv))
Copying media files to configured storage...
Traceback (most recent call last):
  File "/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "wagtailcore_site" does not exist
LINE 1: SELECT (1) AS "a" FROM "wagtailcore_site" WHERE "wagtailcore...
                               ^


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/code/manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line
    utility.execute()
  File "/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/venv/lib/python3.9/site-packages/django/core/management/base.py", line 373, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/venv/lib/python3.9/site-packages/django/core/management/base.py", line 417, in execute
    output = self.handle(*args, **options)
  File "/code/bakerydemo/base/management/commands/load_initial_data.py", line 36, in handle
    if Site.objects.filter(hostname='localhost').exists():
  File "/venv/lib/python3.9/site-packages/django/db/models/query.py", line 815, in exists
    return self.query.has_results(using=self.db)
  File "/venv/lib/python3.9/site-packages/django/db/models/sql/query.py", line 549, in has_results
    return compiler.has_results()
  File "/venv/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1172, in has_results
    return bool(self.execute_sql(SINGLE))
  File "/venv/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1202, in execute_sql
    cursor.execute(sql, params)
  File "/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/venv/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "wagtailcore_site" does not exist
LINE 1: SELECT (1) AS "a" FROM "wagtailcore_site" WHERE "wagtailcore...
                               ^