2017-12-20 25 views
0

DjangoプロジェクトでGitLabのCIを使用する際に問題が発生しました。私はpostgresサーバーを使用していると私は間違って何かを設定しているようだ。どんな助けでも大歓迎です!GitLab CI DjangoとPostgres

エラー:

django.db.utils.OperationalError: could not connect to server: No such file or directory 
    Is the server running locally and accepting 
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? 

マイ.gitlab-ci.ymlファイル:私のDjangoの設定ファイルで

image: python:3.6.1 

services: 
    - postgres:9.3 

variables: 
    POSTGRES_DB: project_ci_test 
    POSTGRES_USER: postgres 
    POSTGRES_PASSWORD: "" 

test: 
    script: 
    - export DATABASE_URL=postgres://postgres:@postgres:5432/project_ci_test 
    - apt-get update -qy 
    - apt-get install -y python-dev python-pip 
    - pip install -r requirements.txt 
    - python manage.py makemigrations 
    - python manage.py migrate 
    - python manage.py test Project 

:私は現在、GitLabのを利用しようとしています

DATABASES = { 
    'default': { 
     'ENGINE' : 'django.db.backends.postgresql_psycopg2', 
     'NAME' : 'project_ci_test', 
     'USER' : 'postgres', 
     'PASSWORD': '', 

    } 
} 

共有ランナー。私はGitLabのCIで作業するために誰かがPostgresのDjangoプロジェクトを正常に取得したことを期待しています。

ありがとうございます!

答えて

0

最後に問題を見つけました。 Djangoプロジェクトの設定ファイルでホストとポートを指定すると、問題が解決しました。

DATABASES = { 
    'default': { 
     'ENGINE' : 'django.db.backends.postgresql_psycopg2', 
     'NAME' : 'project_ci_test', 
     'USER' : 'postgres', 
     'PASSWORD': '', 
     'HOST' : 'postgres' 
     'PORT' : '5432' 

    } 
}