Есть два каталога:
Рабочий:
Для тестов другого человека:
docker-compose запускается внутри рабочего каталога, но не запускается внутри тестового. При попытке запустить контейнер приложения в тестовом каталоге, вылезает трейсбек:
Traceback (most recent call last):
File "/webapp/manage.py", line 22, in
main()
File "/webapp/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 414, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 455, in execute
self.check()
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 487, in check
all_issues = checks.run_checks(
File "/usr/local/lib/python3.9/site-packages/django/core/checks/registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/usr/local/lib/python3.9/site-packages/django/core/checks/urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "/usr/local/lib/python3.9/site-packages/django/core/checks/urls.py", line 24, in check_resolver
return check_method()
File "/usr/local/lib/python3.9/site-packages/django/urls/resolvers.py", line 480, in check
for pattern in self.url_patterns:
File "/usr/local/lib/python3.9/site-packages/django/utils/functional.py", line 49, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.9/site-packages/django/urls/resolvers.py", line 696, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python3.9/site-packages/django/utils/functional.py", line 49, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.9/site-packages/django/urls/resolvers.py", line 689, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "", line 850, in exec_module
File "", line 228, in _call_with_frames_removed
File "/webapp/app/urls.py", line 4, in
from account.routers import users
File "/webapp/account/routers.py", line 1, in
from rest_framework.routers import DefaultRouter
File "/usr/local/lib/python3.9/site-packages/rest_framework/routers.py", line 22, in
from rest_framework import views
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 17, in
from rest_framework.schemas import DefaultSchema
File "/usr/local/lib/python3.9/site-packages/rest_framework/schemas/__init__.py", line 33, in
authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
File "/usr/local/lib/python3.9/site-packages/rest_framework/settings.py", line 225, in __getattr__
val = perform_import(val, attr)
File "/usr/local/lib/python3.9/site-packages/rest_framework/settings.py", line 168, in perform_import
return [import_from_string(item, setting_name) for item in val]
File "/usr/local/lib/python3.9/site-packages/rest_framework/settings.py", line 168, in
return [import_from_string(item, setting_name) for item in val]
File "/usr/local/lib/python3.9/site-packages/rest_framework/settings.py", line 177, in import_from_string
return import_string(val)
File "/usr/local/lib/python3.9/site-packages/django/utils/module_loading.py", line 30, in import_string
return cached_import(module_path, class_name)
File "/usr/local/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 "/usr/local/lib/python3.9/site-packages/rest_framework_simplejwt/authentication.py", line 6, in
from .settings import api_settings
File "/usr/local/lib/python3.9/site-packages/rest_framework_simplejwt/settings.py", line 20, in
'SIGNING_KEY': settings.SECRET_KEY,
File "/usr/local/lib/python3.9/site-packages/django/conf/__init__.py", line 95, in __getattr__
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
В .app_env прописан DJANGO_SECRET_KEY, а settings.py:
SECRET_KEY = os.getenv('DJANGO_SECRET_KEY')
файл docker-compose.yaml:
version: "3.9"
services:
redis:
image: redis
restart: always
env_file:
- .app_env
servis_db:
image: postgres
container_name: servis_db
volumes:
- pg_data:/var/lib/postgresql/data/
env_file:
- .app_env
webapp:
build: app
command: sh -c "python manage.py makemigrations
&& python manage.py migrate
&& python manage.py add_admin
&& python manage.py collectstatic --noinput
&& python manage.py runserver 0.0.0.0:8000"
volumes:
- ./project:/project
- static_data:/project/static
ports:
- "8000:8000"
depends_on:
- servis_db
env_file:
- .app_env
celery:
build: app
command: sh -c "celery -A app worker -l INFO"
depends_on:
- redis
env_file:
- .app_env
volumes:
static_data:
pg_data: