I'm trying to access mongorestore/mongodump commands from within a docker image that's been run via gitlab-ci-multirunner.
My .gitlab-ci.yml looks something like this:
image: node:7.2.0
cache:
key: "$CI_BUILD_REF_NAME"
paths:
- node_modules/
services:
- mongo
variables:
DOCKER_ENV: 'true'
NODE_ENV: 'test'
all_tests:
script:
- npm install
- npm install tsd -g
- tsd install --save
- node_modules/typescript/bin/tsc -p .
- node node_modules/mocha/bin/_mocha --recursive tests --timeout 15000
In my tests I do mongodump/mongorestore. The error I get is:
Create Transaction Tests
Connected to MongoDB: mongodb://mongo:27017/test-db { Error: Command failed: mongorestore --port 27017 --drop /builds/project/repo/project/tests/testData/db/mongo/dump
/bin/sh: 1: mongorestore: not found
I have even tried running a mongorestore command with "docker run" in the scripts section:
- docker run --rm --link mongodb:mongo -v /root:/backup mongo bash -c ‘mongorestore /backup --host $MONGO_PORT_27017_TCP_ADDR’
I get this error:
/bin/bash: line 61: docker: command not found
I have to mention that I'm running this image on a shared docker runner provided by gitlab.
Any advice on how I can access "mongorestore" command from within my test?
Not the most elegant solution, but you can always create your own image on top of node:7.2.0 that has mongo installed, thus allowing the container to execute mongodump/restore. A Dockerfile for such an image should look like so -
FROM node:7.2.0
RUN apt-get update -y && \
apt-get install -y mongodb
Then you can pull this image instead of the normal node image, and have mongo cli at your disposal.