Gitlab pipeline with integrated mongodb

I am trying to build a pipeline for a gradle java application that uses a built-in instance of mongo. I built a container that has java and mongo in it. However, I keep getting the following error for all my tests that require a built-in instance of mongo.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'embeddedMongoServer' 
defined in class path resource [org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.class]: 
Invocation of init method failed; nested exception is java.io.IOException: 
Cannot run program "/tmp/extract-f816c11c-614b-46d7-ad29-68923ca9d624extractmongod": error=2, No such file or directory

My is gitlab-ci.ymlas follows:

image: java:latest
services:
  - docker:dind

variables:
  GRADLE_OPTS: "-Dorg.gradle.daemon=false"
  DOCKER_DRIVER: overlay
  SPRING_PROFILES_ACTIVE: gitlab-ci

stages:
  - build
  - test

build:
  stage: build
  script: ./gradlew --build-cache assemble
  cache:
    key: "$CI_COMMIT_REF_NAME"
    policy: push
    paths:
      - build
      - .gradle

test:
  stage: test
  image: registry.gitlab.com/path/to/explorer-ci:1.0.0
  script: ./gradlew check --debug
  cache:
    key: "$CI_COMMIT_REF_NAME"
    policy: pull
    paths:
      - build
      - .gradle

The build task is working fine, the test task is not working. My explorer-ci container is built using the following Dockerfile

FROM openjdk:8-jdk-alpine

RUN apk update && \
    apk add --no-cache \
        mongodb \
        bash

VOLUME /data/db
VOLUME log

RUN ["mongod", "--smallfiles", "--fork", "--logpath", "log/mongodb.log"]

I spent a week with a bunch of different configurations, but it seemed that I could not crack it. Just note that builds / tests run fine on my local machine. Any ideas on what I'm doing wrong?

+4
source share
1

, mongo, mongodb . gitlab-ci.yaml, .

image: openjdk:8-jdk

variables:
  GRADLE_OPTS: "-Dorg.gradle.daemon=false"
  DOCKER_DRIVER: overlay
  SPRING_PROFILES_ACTIVE: gitlab-ci

stages:
  - build
  - test

build:
  stage: build
  script: ./gradlew --build-cache assemble
  cache:
    key: "$CI_COMMIT_REF_NAME"
    policy: push
    paths:
      - build
      - .gradle

test:
  stage: test
  script: ./gradlew check
  cache:
    key: "$CI_COMMIT_REF_NAME"
    policy: pull
    paths:
      - build
      - .gradle
+1

Source: https://habr.com/ru/post/1695351/


All Articles