How to reach a running container within gitlab runner
I've been experiencing an issue and even with all I could read on the web, I keep on getting stuck...
I've developed an "abstraction" for MongoDB and I've made some Unit tests and some E2E tests. For the "End to End" tests, I need MongoDB to run within my pipeline. Yesterday I was on CloudBuild but today I am on Gitlab and... I am not able anymore to run these tests...
I have the following:
gitlab-ci.yml
image: docker:latest
services:
- docker:dind
variables:
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: "tcp://docker:2375"
stages:
- test
.anchors:
- &start-mongodb-docker-compose
apk add --no-cache docker-compose
&& docker-compose -f e2e_tests/docker-compose.yml up --build -d
integration-tests:
image: golang:1.16
stage: test
before_script:
- *start-mongodb-docker-compose
script:
- make test
only:
- master
e2e_tests/docker-compose.yml
version: "3.7"
services:
mongodb:
container_name: MongoDB_E2E
image: mongo
restart: always
ports:
- "27017:27017"
Makefile
PROJECT_NAME="yyyyyy"
PKG="gitlab.com/xxxxxx/$(PROJECT_NAME)"
.PHONY: all
all: test
test: unit-tests e2e-tests
unit-tests: ## Run unittests
@go test -v ./... --tags=unit
e2e-tests: ## Run end-to-end tests
@go test -v ./... -p 1 --tags=e2e
coverage: ## Generate global code coverage report
@go test -v -coverprofile .testCoverage.txt
As you can see, I already tried some from the web, such as DOCKER_HOST but.. nothing worked as of now. If anyone has an idea, I would love to hear about it. I also tried to set the network as I did for CloudBuild but it didn't work either...
Thanks for any help!
Max