I am having an issue getting GitLab's CI to work with my Django project. I am using a postgres server and it appears I have set something up wrong. Any help would be much appreciated!
The error:
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"?
My .gitlab-ci.yml file:
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 my django settings file:
DATABASES = {
'default': {
'ENGINE' : 'django.db.backends.postgresql_psycopg2',
'NAME' : 'project_ci_test',
'USER' : 'postgres',
'PASSWORD': '',
}
}
I am currently trying to utilize GitLab's shared runners. I am hoping someone has successfully gotten a Django project with postgres to work on GitLab's CI.
Thanks!
Finally figured out the problem. Specifying the host and port in my Django project's settings file resolved the issue!
DATABASES = {
'default': {
'ENGINE' : 'django.db.backends.postgresql_psycopg2',
'NAME' : 'project_ci_test',
'USER' : 'postgres',
'PASSWORD': '',
'HOST' : 'postgres'
'PORT' : '5432'
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With