Python/Django/Docker/Docker-Compose, why can't be picked up by the container from pytest'a?

0 like 0 dislike
13 views
There is a project on Django.
Also there are containers postgres, redis, web(application)
When you launch the app, it's okay to hem the container with the base, but pytesta can't swear on unknown service "postgres"
pytest.ini
[pytest] addopts = --reuse-db --no-migrations DJANGO_SETTINGS_MODULE = core.settings python_files = tests.py test_*.py *_tests.py

As settings use local_settings at the end of the settings file you want to import local settings if they exist.
local_settings
from .settings import * DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'provizorro', 'USER': 'provizorro', 'PASSWORD': 'Provizorro666', 'HOST': 'postgres' 'PORT': 5432, } } DEBUG = True CELERY_BROKER_URL = 'redis://127.0.0.1:6001' CELERY_BROKER_BACKEND = "redis" CELERY_REDIS_PORT = 6001 CELERY_REDIS_HOST = "localhost" CELERY_RESULT_BACKEND = 'redis://'

And docker-compose
version: '3' services: postgres: image: postgres ports: - "5001:5432" environment: POSTGRES_DB: provizorro POSTGRES_USER: provizorro POSTGRES_PASSWORD: Provizorro666 volumes: - /home/sergey/Projects/data-pg:/var/lib/postgresql/data redis: image: redis ports: - "6001:6379" web: restart: always build: . command: bash -c "python3.6 src/manage.py runserver 0.0.0.0:8000" ports: - "8000:8000" volumes: - .:/code depends_on: - postgres - redis
by | 13 views

1 Answer

0 like 0 dislike
Perhaps we need to wait for startup of container database using the script wait-for-it: https://docs.docker.com/compose/startup-order/
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
28,659 users