如何 运行 stub-运行ner docker image with local repo
How to run stub-runner docker image with local repo
我尝试 运行 将 运行ner docker 图像与本地存储库存根,如下所示,
STUBRUNNER_IDS="cn.xxx.accounting:accounting-configserver:1.0.0:stubs:9876"
STUBRUNNER_REPOSITORY_ROOT="file:///m2/repository"
STUBRUNNER_PORT="8083"
SC_CONTRACT_DOCKER_VERSION=2.0.0.RC2
docker run --rm --interactive --tty -e "STUBRUNNER_IDS=${STUBRUNNER_IDS}" -e "REPO_WITH_BINARIES_URL=${STUBRUNNER_REPOSITORY_ROOT}" -p "${STUBRUNNER_PORT}:${STUBRUNNER_PORT}" -p "9876:9876" -v ~/.m2:/m2 springcloud/spring-cloud-contract-stub-runner:"${SC_CONTRACT_DOCKER_VERSION}"
然后我得到以下错误,
Caused by: org.springframework.beans.BeanInstantiationException:
Failed to instantiate
[org.springframework.cloud.contract.stubrunner.BatchStubRunner]:
Factory method 'batchStubRunner' threw exception; nested exception is
java.lang.IllegalStateException: No stubs were found on classpath for
[cn.xxx.accounting:accounting-configserver]
看起来存根 运行ner 正在使用类路径查找存根。如何将存根模式更改为本地?我找不到 spring-cloud-contract-stub-runner
的 docker 文件的来源。任何环境都那么棘手吗?
当然,将本地 .m2 的体积附加到容器中的体积就足够了。您还需要传递 STUBRUNNER_STUBS_MODE=REMOTE
(https://github.com/spring-cloud/spring-cloud-contract/blob/master/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/StubRunnerProperties.java#L100)
#!/bin/bash
SC_CONTRACT_DOCKER_VERSION="${SC_CONTRACT_DOCKER_VERSION:-1.2.4.BUILD-SNAPSHOT}"
APP_IP="$( ./whats_my_ip.sh )"
# Stub coordinates 'groupId:artifactId:version:classifier'
STUB_GROUP="${STUB_GROUP:-com.example}"
STUB_ARTIFACT="${STUB_ARTIFACT:-bookstore}"
STUB_VERSION="${STUB_VERSION:-0.0.1.RELEASE}"
STUB_PORT="9876"
# Spring Cloud Contract Stub Runner properties
STUBRUNNER_PORT="${STUBRUNNER_PORT:-8083}"
STUBRUNNER_IDS="${STUB_GROUP}:${STUB_ARTIFACT}:${STUB_VERSION}:stubs:${STUB_PORT}"
STUBRUNNER_REPOSITORY_ROOT="http://${APP_IP}:8081/artifactory/libs-release-local"
docker run --rm -e "STUBRUNNER_IDS=${STUBRUNNER_IDS}" -e "SERVER_PORT=${STUBRUNNER_PORT}" -e "STUBRUNNER_REPOSITORY_ROOT=${STUBRUNNER_REPOSITORY_ROOT}" -p "${STUBRUNNER_PORT}:${STUBRUNNER_PORT}" -p "${STUB_PORT}:${STUB_PORT}" -v ~/.m2:/root/m2 springcloud/spring-cloud-contract-stub-runner:"${SC_CONTRACT_DOCKER_VERSION}"
请注意,我们正在使用 maven local 或我们的 docker 图像,但它指向 ${USER_HOME}/.m2
AFAIR 是 /root/.m2
in Docker。
我尝试 运行 将 运行ner docker 图像与本地存储库存根,如下所示,
STUBRUNNER_IDS="cn.xxx.accounting:accounting-configserver:1.0.0:stubs:9876"
STUBRUNNER_REPOSITORY_ROOT="file:///m2/repository"
STUBRUNNER_PORT="8083"
SC_CONTRACT_DOCKER_VERSION=2.0.0.RC2
docker run --rm --interactive --tty -e "STUBRUNNER_IDS=${STUBRUNNER_IDS}" -e "REPO_WITH_BINARIES_URL=${STUBRUNNER_REPOSITORY_ROOT}" -p "${STUBRUNNER_PORT}:${STUBRUNNER_PORT}" -p "9876:9876" -v ~/.m2:/m2 springcloud/spring-cloud-contract-stub-runner:"${SC_CONTRACT_DOCKER_VERSION}"
然后我得到以下错误,
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.contract.stubrunner.BatchStubRunner]: Factory method 'batchStubRunner' threw exception; nested exception is java.lang.IllegalStateException: No stubs were found on classpath for [cn.xxx.accounting:accounting-configserver]
看起来存根 运行ner 正在使用类路径查找存根。如何将存根模式更改为本地?我找不到 spring-cloud-contract-stub-runner
的 docker 文件的来源。任何环境都那么棘手吗?
当然,将本地 .m2 的体积附加到容器中的体积就足够了。您还需要传递 STUBRUNNER_STUBS_MODE=REMOTE
(https://github.com/spring-cloud/spring-cloud-contract/blob/master/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/StubRunnerProperties.java#L100)
#!/bin/bash
SC_CONTRACT_DOCKER_VERSION="${SC_CONTRACT_DOCKER_VERSION:-1.2.4.BUILD-SNAPSHOT}"
APP_IP="$( ./whats_my_ip.sh )"
# Stub coordinates 'groupId:artifactId:version:classifier'
STUB_GROUP="${STUB_GROUP:-com.example}"
STUB_ARTIFACT="${STUB_ARTIFACT:-bookstore}"
STUB_VERSION="${STUB_VERSION:-0.0.1.RELEASE}"
STUB_PORT="9876"
# Spring Cloud Contract Stub Runner properties
STUBRUNNER_PORT="${STUBRUNNER_PORT:-8083}"
STUBRUNNER_IDS="${STUB_GROUP}:${STUB_ARTIFACT}:${STUB_VERSION}:stubs:${STUB_PORT}"
STUBRUNNER_REPOSITORY_ROOT="http://${APP_IP}:8081/artifactory/libs-release-local"
docker run --rm -e "STUBRUNNER_IDS=${STUBRUNNER_IDS}" -e "SERVER_PORT=${STUBRUNNER_PORT}" -e "STUBRUNNER_REPOSITORY_ROOT=${STUBRUNNER_REPOSITORY_ROOT}" -p "${STUBRUNNER_PORT}:${STUBRUNNER_PORT}" -p "${STUB_PORT}:${STUB_PORT}" -v ~/.m2:/root/m2 springcloud/spring-cloud-contract-stub-runner:"${SC_CONTRACT_DOCKER_VERSION}"
请注意,我们正在使用 maven local 或我们的 docker 图像,但它指向 ${USER_HOME}/.m2
AFAIR 是 /root/.m2
in Docker。