是否可以在GitLab配置项中配置N个postgresql服务示例?

ki0zmccv  于 2023-01-30  发布在  PostgreSQL
关注(0)|答案(1)|浏览(118)

有没有办法在Gitlab配置项中配置5个postgresql示例?
这是我的配置:

image: something:latest

variables:
  SPRING_PROFILES_ACTIVE: gitlab-ci
  POSTGRES_USER: gitlab-ci
  POSTGRES_PASSWORD: gitlab-ci
  POSTGRES_DB: DATA_V1
  LDAP_DOMAIN: domain.com
  LDAP_ORGANISATION: org
  LDAP_ADMIN_PASSWORD: hello-ci

services:
- name: docker:dind
- name: osixia/openldap:1.1.9
- name: postgres:10.0-alpine
  alias: user-management-db
- name: postgres:10.0-alpine
  alias: company-management-db

它在配置项中生成错误:

[0;m[0KStarting service docker:dind ...
[0;m[0KPulling docker image docker:dind ...
[0;m[0KUsing docker image docker:dind ID=sha256:4998cc824d9ac8e4be3bb89afa004c87911e796cde15f0676d437fcb8a8dd06b for docker service...
[0;m[0KStarting service osixia/openldap:1.1.9 ...
[0;m[0KPulling docker image osixia/openldap:1.1.9 ...
[0;m[0KUsing docker image osixia/openldap:1.1.9 ID=sha256:0670342c5b82a10b014f0cf1060752ccb740cd8bd28a704ac3fa1191a4e31594 for osixia/openldap service...
[0;m[0KStarting service postgres:10.0-alpine ...
[0;m[0KPulling docker image postgres:10.0-alpine ...
[0;m[0KUsing docker image postgres:10.0-alpine ID=sha256:0f0ff37589e948e31d9e64bb6c1b31cdbd4d7d0336b656cb6094be568e54ad04 for postgres service...
[0;m[0;33mWARNING: Service postgres:10.0-alpine is already created. Ignoring.
[0;m[0KStarting service postgres:10.0-alpine ...
[0;m[0KPulling docker image postgres:10.0-alpine ...
[0;m[0KUsing docker image postgres:10.0-alpine ID=sha256:0f0ff37589e948e31d9e64bb6c1b31cdbd4d7d0336b656cb6094be568e54ad04 for postgres service...
[0;m[0;33mWARNING: Service postgres:10.0-alpine is already created. Ignoring.
[0;m[0KStarting service postgres:10.0-alpine ...
[0;m[0KPulling docker image postgres:10.0-alpine ...
[0;m[0KUsing docker image postgres:10.0-alpine ID=sha256:0f0ff37589e948e31d9e64bb6c1b31cdbd4d7d0336b656cb6094be568e54ad04 for postgres service...
[0;m[0;33mWARNING: Service postgres:10.0-alpine is already created. Ignoring.
[0;m[0KStarting service postgres:10.0-alpine ...
[0;m[0KPulling docker image postgres:10.0-alpine ...
[0;m[0KUsing docker image postgres:10.0-alpine ID=sha256:0f0ff37589e948e31d9e64bb6c1b31cdbd4d7d0336b656cb6094be568e54ad04 for postgres service...
[0;m[0;33mWARNING: Service postgres:10.0-alpine is already created. Ignoring.
[0;m[0KStarting service postgres:10.0-alpine ...
[0;m[0KPulling docker image postgres:10.0-alpine ...
[0;m[0KUsing docker image postgres:10.0-alpine ID=sha256:0f0ff37589e948e31d9e64bb6c1b31cdbd4d7d0336b656cb6094be568e54ad04 for postgres service...
[0;m[0;33mWARNING: Service postgres:10.0-alpine is already created. Ignoring.
[0;m[0KStarting service postgres:10.0-alpine ...
[0;m[0KPulling docker image postgres:10.0-alpine ...
[0;m[0KUsing docker image postgres:10.0-alpine ID=sha256:0f0ff37589e948e31d9e64bb6c1b31cdbd4d7d0336b656cb6094be568e54ad04 for postgres service...
[0;m[0;33mWARNING: Service postgres:10.0-alpine is already created. Ignoring.

也不能用variables单独配置。
到目前为止,我的解决方法是只创建一个服务,并使用多个数据库,这并不总是可能的(例如两个LDAP)。
有人在Gitlab-CI中尝试过这样的配置吗?
似乎已在gitlab 9.3 https://gitlab.com/gitlab-org/gitlab-runner/merge_requests/639/pipelines中修复

js81xvg6

js81xvg61#

有可能。比如说:

unit-test:
  services:
    - name: registry.company.com/postgres:14.6
      alias: db1
      variables:
        POSTGRES_DB: "db1"
        POSTGRES_USER: "user1"
        POSTGRES_PASSWORD: "pw1"
        POSTGRES_INITDB_ARGS: "--encoding=UTF8 --no-locale"
    - name: registry.company.com/postgres:14.6
      alias: db2
      variables:
        POSTGRES_DB: "db2"
        POSTGRES_USER: "user2"
        POSTGRES_PASSWORD: "pw2"
        POSTGRES_INITDB_ARGS: "--encoding=UTF8 --no-locale"

这将启动两个postgress,一个可以在主机名db1下访问,另一个可以在主机名db2下访问。
以下是文档:https://docs.gitlab.com/ee/ci/services/index.html#available-settings-for-services

相关问题