I'm including an integration test into my application using library "https://www.testcontainers.org/".
This library need a docker environment to run "gradlew test" command.
How would you use a docker image (which include docker and Gradle) in a gitlab-ci.yml
?
CodePudding user response:
That looks like what Christos Sotiriou described in "Your Private CI/CD using self-hosted GitLab and Docker" in 2020.
It involves a GitLab runner:
A GitLab runner has many modes it can operate, which represent how the build will be performed. Among other modes, there is support for spawning Kubernetes pods, or Docker containers to perform builds.
For the sake of simplicity, we will use the plain docker mode, which will spawn a new container with an image of your choice (determined by your Dockerfile)
Run the following to your terminal:
docker run -d --name gitlab-runner --restart always \ -v /srv/gitlab-runner/config:/etc/gitlab-runner \ -v /var/run/docker.sock:/var/run/docker.sock \ gitlab/gitlab-runner:latest
And:
You can configure your runner to use the host's docker when executing the Dockerfile commands.
You can do that by configuring the gitlab-runner configuration to use the host docker.
That involves some security risk, but check if this option would allow you to use the image you want, while using docker commands in your gitlab-ci.yml
.