简体   繁体   中英

Gitlab-ci image with docker and java/gradle

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 ?

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 Kube.netes 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM