As part of our tests we need to bootstrap a mongo database, but we are running into issues. Part of this appears to be a mismatch between the running mongo service and the mongo-tools
available, via apt install -y mongo-tools
.
We see mongo service running as 6.0.1 and the available mongo-tools as 3.4.14-4.
Having mongo-tools only at 3.4 is really old. Is this intentional?
We ended up having to add the following lines to the before_script
step in our .gitlab-ci.yml
file:
- wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
- echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/6.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
- apt-get update
- apt-get install -y mongodb-org-tools
So that the first part now reads as:
image: node:16
cache:
key: "$CI_BUILD_REF_NAME"
paths:
- node_modules/
services:
- mongo
- redis:latest
stages:
- tests
- deploy
before_script:
# deal with private key
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo -n "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
# deal with host key
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- grep NAME /etc/*-release
- uname -a
- wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add -
- echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/6.0 main" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list
- apt-get update
- apt-get install -y rsync
- apt-get install -y jq
- apt-get install -y mongodb-org-tools