2017-12-20 39 views
0

Ich habe ein Problem, das GitLab CI mit meinem Django-Projekt zu arbeiten. Ich benutze einen Postgres-Server und es scheint, dass ich etwas falsch eingerichtet habe. Jede Hilfe würde sehr geschätzt werden!GitLab CI Django und Postgres

Der Fehler:

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"? 

Meine .gitlab-ci.yml Datei:

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 

In meiner django Einstellungsdatei:

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

    } 
} 

ich derzeit versuche Gitlab die zu nutzen geteilte Läufer. Ich hoffe, dass jemand erfolgreich ein Django-Projekt mit Postgres erhalten hat, um an GitLabs CI zu arbeiten.

Danke!

Antwort

0

Schließlich herausgefunden, das Problem. Durch die Angabe des Hosts und des Ports in der Einstellungsdatei meines Django-Projekts wurde das Problem behoben!

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

    } 
}