我有一个免费的 gitlab 帐户。我还有一个公司帐户(不确定哪个计划)。
我有完全相同的项目,EventStore 上的一个包装器。
在 CI 管道中,我想启动一个带有事件存储的容器,以便我可以针对它运行一些集成测试。
这是我.gitlab-ci.yml
的恢复、编译、运行测试和发布 nuget 包
#Stages
stages:
- ci
- pack
#Global variables
variables:
GITLAB_RUNNER_DOTNET_CORE: mcr.microsoft.com/dotnet/core/sdk:2.2
EVENT_STORE: eventstore/eventstore:release-5.0.2
NUGET_REPOSITORY: $NEXUS_NUGET_REPOSITORY
NUGET_API_KEY: $NEXUS_API_KEY
NUGET_FOLDER_NAME: nupkgs
#Docker image
image: $GITLAB_RUNNER_DOTNET_CORE
#Jobs
ci:
stage: ci
services:
- $EVENT_STORE
variables:
# event store service params testing with standard ports
EVENTSTORE_INT_TCP_PORT: "1113"
EVENTSTORE_EXT_TCP_PORT: "1113"
EVENTSTORE_INT_HTTP_PORT: "2113"
EVENTSTORE_EXT_HTTP_PORT: "2113"
EVENTSTORE_EXT_HTTP_PREFIXES: "http://*:2113/"
script:
- dotnet restore --no-cache --force
- dotnet build --configuration Release
- dotnet vstest test/*Tests/bin/Release/**/*Tests.dll
pack-beta-nuget:
stage: pack
script:
- export VERSION_SUFFIX=beta$CI_PIPELINE_ID
- dotnet pack *.sln --configuration Release --output $NUGET_FOLDER_NAME --version-suffix $VERSION_SUFFIX --include-source --include-symbols -p:SymbolPackageFormat=snupkg
- dotnet nuget push **/*.nupkg --api-key $NUGET_API_KEY --source $NUGET_REPOSITORY
except:
- master
pack-nuget:
stage: pack
script:
- dotnet restore
- dotnet pack *.sln --configuration Release --output $NUGET_FOLDER_NAME
- dotnet nuget push **/*.nupkg --api-key $NUGET_API_KEY --source $NUGET_REPOSITORY
only:
- master
如您所见,我启动了事件存储容器。
从我的集成测试中,我尝试使用以下连接字符串连接到 CI 中的容器:
"ConnectTo=tcp://admin:changeit@127.0.0.1:1113; HeartBeatTimeout=500;";
使用我的工作帐户,它可以正常工作,有一个容器在端口 1113 上侦听 127.0.0.1,我可以使用上面的连接字符串连接到它。
使用我的免费个人帐户无法连接。
为什么?
我怀疑这与 docker 在两个 gitlab CI 运行器上都可用的方式有关,但为什么不同呢?
更重要的是,如何在我的免费帐户上的个人 CI 管道上配置事件存储,以便在 localhost 由于某种原因不是有效的主机 Uri 时可以连接到它?