diff --git a/Dockerfile b/Dockerfile index 3d76552c0e56..57373b565ae1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # Read the docs/topics/development/docker.md file for more information about this Dockerfile. #################################################################################################### -FROM python:3.10-slim-buster as base +FROM python:3.10-slim-bookworm as base # Should change it to use ARG instead of ENV for OLYMPIA_UID/OLYMPIA_GID # once the jenkins server is upgraded to support docker >= v1.9.0 @@ -43,6 +43,7 @@ RUN touch /addons-server-docker-container \ # Git, because we're using git-checkout dependencies git \ # Dependencies for mysql-python (from mysql apt repo, not debian) + pkg-config \ mysql-client \ libmysqlclient-dev \ swig \ diff --git a/docker/mysql.list b/docker/mysql.list index fad8e9518746..0fafbfd8a1a3 100644 --- a/docker/mysql.list +++ b/docker/mysql.list @@ -1 +1 @@ -deb http://repo.mysql.com/apt/debian/ buster mysql-8.0 +deb http://repo.mysql.com/apt/debian/ bookworm mysql-8.0 diff --git a/src/olympia/core/apps.py b/src/olympia/core/apps.py index ddf34506f549..e0e675d7b028 100644 --- a/src/olympia/core/apps.py +++ b/src/olympia/core/apps.py @@ -1,14 +1,37 @@ import logging +import subprocess import warnings from django.apps import AppConfig from django.conf import settings +from django.core.checks import Error, Tags, register from django.utils.translation import gettext_lazy as _ log = logging.getLogger('z.startup') +class CustomTags(Tags): + custom_setup = 'setup' + + +@register(CustomTags.custom_setup) +def uwsgi_check(app_configs, **kwargs): + """Custom check triggered when ./manage.py check is ran (should be done + as part of verifying the docker image in CI).""" + errors = [] + command = ['uwsgi', '--version'] + result = subprocess.run(command, capture_output=True) + if result.returncode != 0: + errors.append( + Error( + f'{" ".join(command)} returned a non-zero value', + id='setup.E001', + ) + ) + return errors + + class CoreConfig(AppConfig): name = 'olympia.core' verbose_name = _('Core') diff --git a/src/olympia/core/tests/test_apps.py b/src/olympia/core/tests/test_apps.py new file mode 100644 index 000000000000..7fefd167d20d --- /dev/null +++ b/src/olympia/core/tests/test_apps.py @@ -0,0 +1,17 @@ +from unittest import mock + +from django.core.management import call_command +from django.core.management.base import SystemCheckError +from django.test import SimpleTestCase + + +class SystemCheckIntegrationTest(SimpleTestCase): + def test_uwsgi_check(self): + call_command('check') + + with mock.patch('olympia.core.apps.subprocess') as subprocess: + subprocess.run.return_value.returncode = 127 + with self.assertRaisesMessage( + SystemCheckError, 'uwsgi --version returned a non-zero value' + ): + call_command('check')