Start single node Replica Set in GitLab CI

I’ve found a workaround installing MongoDB within the image

stages:
  - test
test:
  stage: test
  image: python:3.8-bullseye 
  services:
    - name: mongo:latest
      command:    [
          "/bin/sh",
          "-c",
          "mongod --logpath /dev/null --bind_ip_all --replSet 'rs0'",
        ]
  before_script:
    - wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc |  apt-key add -
    - echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main" |  tee /etc/apt/sources.list.d/mongodb-org-5.0.list
    - apt-get update
    - apt-get install -y mongodb-org
    - mongo --host mongo --eval "rs.initiate()"   
  variables:
    MONGODB_HOST: mongo:27017
    PYTHONWARNINGS: ignore::DeprecationWarning
  script:
    - mongo --host mongo --eval 'rs.status()'
1 Like