Hi guys,
I’ve searched high and low for a quick simple solution to my problem but am struggling.
I have a simple script in my node js project which will spin up a redis docker container on port 6378 (not the default 6379). This is to help my integration tests avoid port collisions on my local environment.
When I run my tests on CircleCI, I get the following error:
Redis connection to localhost:6378 failed - connect ECONNREFUSED 127.0.0.1:6378
Here is my config.yml:
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/node:13
working_directory: ~/repo
steps:
- checkout
- setup-remote-docker
- run: echo "lerna installing"
- run: sudo npm install -g lerna
- run: sudo npm i
- run: lerna bootstrap
# build, lint, test!
- run: npm run build
- run: npm run lint
- run: npm run test
workflows:
version: 2
build_deploy:
jobs:
- build
I have seen from my searching that we aren’t allowed permissions to change the ports and that docker-compose may be a good alternative, however I don’t know how to set this up. Any pointers?
Thank you.
Edit:
Here are the npm scripts that set up the container and run the tests:
"test:int": "npm run redis-test:start && jest --passWithNoTests --forceExit --runInBand --testRegex ispec\\.ts$ && npm run redis-test:stop",
"redis-test:start": "echo Starting up redis integration testing server && docker run --name redis-testing -d -p 6378:6379 redis",
"redis-test:stop": "echo Stopping redis integration testing server && docker rm $(docker stop $(docker ps -a -q --filter=\"name=redis-testing\"))"