Мой GitLabCI:
stages:
- test
# jobs
test_django:
stage: test
image: python:3.6 # this pulls the standard python 3.6 docker image
services:
- postgres:9.5 # this pulls a docker image with pgsql on it
variables:
# env vars made available to the script below
CI_DEBUG_TRACE: "false" # set to false to reduce the debug output from the CI jobs
POSTGRES_DB: "project_ci_test"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: ""
DATABASE_NAME: "$POSTGRES_DB"
DATABASE_HOST: "postgres" # magically finds the service above
DATABASE_USER: "postgres"
DATABASE_PASSWORD: ""
DJANGO_SECRET_KEY: "somerandombogusstringtokeepdjangohappyandstartingproperly"
script:
- apt-get update -qy
- apt-get install -y python3-pip wkhtmltopdf xvfb # extra packages used for pdf rendering in the tests
- pip install -r requirements.txt
- pep8 . --filename=*.py --ignore=E128,E265,E501 --repeat
- python manage.py migrate
- python manage.py test
Но теперь я получаю ошибку при выполнении миграций.
Ошибка GitlabCi:
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection
connection = Database.connect(**conn_params)
File "/usr/local/lib/python3.6/site-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not translate host name "postgres" to address: Name or service not known
ERROR: Job failed: exit code 1
Здравствуйте, ребята, не могли бы вы помочь мне. что не так с моими настройками, он работал несколько месяцев go, но не работает.
Django Настройки базы данных:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ.get('DATABASE_NAME', ''),
'USER': os.environ.get('DATABASE_USER', ''),
'PASSWORD': os.environ.get('DATABASE_PASSWORD', ''),
'HOST': os.environ.get('DATABASE_HOST', '127.0.0.1'),
'PORT': '5432',
}
}