作者:真知棒 | 来源:互联网 | 2022-12-23 03:42
我正在尝试为使用嵌入式mongo实例的gradle java应用程序构建管道.我已经构建了一个容器,其中包含java和mongo.但是,对于需要嵌入式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
我gitlab-ci.yml
看起来像这样:
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
构建作业正常,测试作业失败.我的explorer-ci容器是使用以下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"]
我用一堆不同的配置花了一个星期,但似乎无法破解它.请注意,构建/测试在我的本地计算机上运行良好.我做错了什么想法?