Andr Samson
Andr Samson

Reputation: 11

execute testcontainer integration test in gitlab pipeline

I'm quite new to GitLab and docker, I have a pipeline that consists of several steps

for maven build, junit test stages I use image: maven:3-jdk-8 - and add appropriate maven commands in the script section

for docker build and deploy stage I use image: docker:latest - and add appropriate docker commands in the script section

Now - I want to include integration tests based on testcontainers which means I need to execute at least some docker commands and mvn command. Then none of the above-mentioned images is appropriate and some part of my script fails. docker: command not found or mvn: command not found.

Does it mean that I must build and deploy to docker hub my own image that includes required dependencies? Looked for such an image but haven't found it. Or maybe is there a simpler solution? Thanks for any answer.

Upvotes: 1

Views: 2980

Answers (1)

yuppie-flu
yuppie-flu

Reputation: 1490

Have you tried the approach described in Testcontainers documentation? So in your case the provided example of .gitlab-ci.yml would look something like:

# DinD service is required for Testcontainers
services:
  - docker:dind

variables:
  # Instruct Testcontainers to use the daemon of DinD.
  DOCKER_HOST: "tcp://docker:2375"
  # Improve performance with overlayfs.
  DOCKER_DRIVER: overlay2

test:
 image: maven:3-jdk-8
 stage: test
 script: mvn clean verify

Upvotes: 0

Related Questions