Mongodb gitlab CI docker connection refused

Viewed 1336

I am trying to create a docker test enviroment for our opensource hobby project. Our python and angular code is running without errors. I need a little help with configuring the docker runner to include mongodb.

stages: 
- build
- test

services:
  - mongo

variables:
  MONGODB_URI: "mongodb://mongo/projekt_eszkozok"


build: 
  stage: build
  image: "python:3.8.2"
  script:
    - "pip3 install -r sources/backend/requirements.txt"

test:
  stage: test
  image: "python:3.8.2"
  script:
    - "pip3 install -r sources/backend/requirements.txt"
    - cd sources/backend
    - "python -m unittest discover tests/"

The error:

pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused

Also it might matter that the project have Angular frontend which is going to be added to the test enviroment once we made our first Angular test.

Python database config:

MONGODB_SETTINGS = {
    'host': 'mongodb://127.0.0.1:27017/projekt_eszkozok'
}

Also tried with:

MONGODB_SETTINGS = {
    'host': 'mongodb://mongo:27017/projekt_eszkozok'
}
1 Answers
Related