使用mvn-docker插件运行时JIra容器找不到postgresql

时间:2019-08-02 07:32:11

标签: postgresql maven docker docker-compose jira

我们正在开发一个jira插件。对于集成测试,我想在以postgresql作为我的数据库的dockerized容器中运行插件(由于testdata,无法选择来自atlassian-sdk的标准集成测试)。当使用docker-compose运行两个容器时,一切都按预期工作。

当我使用mvn-docker插件时,两个容器都被启动,并且jira容器可以连接到postgres容器。 jira启动在启动检查期间停止并冻结(该容器可访问,并在jira http地址上显示有关数据库问题的一些消息。

postgresql容器给出以下日志消息: 致命:数据库“ jiradb'”不存在

登录到postgres容器,然后成功运行psql -U jira -d jiradb,因此数据库已存在。

使用的docker映像为:

  • postgres:9.5高山
  • ownjira,它基于teamatldocker / jira,仅将我们的插件复制到jira中,否则为teamatldocker / jira映像(请参见下面的Dockerfile)

pom.xml中的Docker-maven插件部分(未找到数据库):

 <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version>${docker.maven.plugin.fabric8.version}</version>
        <configuration>
          <autoCreateCustomNetworks>true</autoCreateCustomNetworks>
          <logDate>default</logDate>
          <autoPull>true</autoPull>
          <verbose>true</verbose>
          <images>
            <image>
              <alias>postgresql</alias>
              <name>postgres:9.5-alpine</name>
              <run>
                <network>
                  <mode>custom</mode>
                  <name>test-network</name>
                  <alias>postgresql</alias>
                  <alias>db-alternative</alias>
                </network>
                <env>
                  <POSTGRES_USER>jira</POSTGRES_USER>
                  <POSTGRES_PASSWORD>jellyfish</POSTGRES_PASSWORD>
                  <POSTGRES_DB>jiradb</POSTGRES_DB>
                  <POSTGRES_ENCODING>UNICODE</POSTGRES_ENCODING>
                  <POSTGRES_COLLATE>C</POSTGRES_COLLATE>
                  <POSTGRES_COLLATE_TYPE>C</POSTGRES_COLLATE_TYPE>
                </env>
                <volumes>
                  <bind>
                    <volume>./postgresqldata/:/var/lib/postgresql/data</volume>
                  </bind>
                </volumes>

                <wait>
                  <log>database system is ready to accept connections</log>
                  <time>200000</time>
                </wait>
                <log>
                  <prefix>DB</prefix>
                  <color>yellow</color>
                </log>
              </run>
            </image>

            <image>
              <alias>jira</alias>
              <!-- <name>teamatldocker/jira</name> -->
              <!-- ownjira is teamatldocker/jira only with a copy of our plugin-->
              <name>ownjira</name>
              <run>
                <network>
                  <mode>custom</mode>
                  <name>test-network</name>
                  <alias>jira</alias>
                </network>
                <env>
                  <JIRA_DATABASE_URL>postgresql://jira@postgresql/jiradb'</JIRA_DATABASE_URL>
                  <JIRA_DB_PASSWORD>jellyfish</JIRA_DB_PASSWORD>
                  <SETENV_JVM_MINIMUM_MEMORY>2048m</SETENV_JVM_MINIMUM_MEMORY>
                  <SETENV_JVM_MAXIMUM_MEMORY>4096m</SETENV_JVM_MAXIMUM_MEMORY>
                  <DOCKER_WAIT_HOST>postgresql</DOCKER_WAIT_HOST>
                  <DOCKER_WAIT_PORT>5432</DOCKER_WAIT_PORT>
                  <JIRA_PROXY_NAME></JIRA_PROXY_NAME>
                  <JIRA_PROXY_PORT></JIRA_PROXY_PORT>
                  <JIRA_PROXY_SCHEME></JIRA_PROXY_SCHEME>
                </env>
                <volumes>
                  <bind>
                    <volume>./jiradata/:/var/atlassian/jira</volume>
                  </bind>
                </volumes>
                <ports>
                  <port>80:8080</port>
                  <port>2990:2990</port>
                </ports>
                <wait>
                  <log>Plugins upgrades completed successfully</log>
                  <time>3000000</time>
                </wait>
                <log>
                  <prefix>JIRA</prefix>
                  <color>cyan</color>
                </log>
              </run>
            </image>
          </images>
        </configuration>

        <!-- Hooking into the lifecycle -->
        <executions>
          <execution>
            <id>start</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>build</goal>
              <goal>start</goal>
            </goals>
          </execution>
          <execution>
            <id>stop</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

docker-compose(一切正常):

version: '3.7'

services:

  jira:
    depends_on:
      - postgresql
    # image: teamatldocker/jira
    image: ownjira
    networks:
      - jiranet
    volumes:
      - ./jiradata/:/var/atlassian/jira
    ports:
      - '80:8080'
      - '2990:2990'
    environment:
      - 'JIRA_DATABASE_URL=postgresql://jira@postgresql/jiradb'
      - 'JIRA_DB_PASSWORD=jellyfish'
      - 'SETENV_JVM_MINIMUM_MEMORY=2048m'
      - 'SETENV_JVM_MAXIMUM_MEMORY=4096m'
      - 'DOCKER_WAIT_HOST=postgresql'
      - 'DOCKER_WAIT_PORT=5432'
      - 'JIRA_PROXY_NAME='
      - 'JIRA_PROXY_PORT='
      - 'JIRA_PROXY_SCHEME='
    logging:
      # limit logs retained on host to 25MB
      driver: "json-file"
      options:
        max-size: "500k"
        max-file: "50"

  postgresql:
    image: postgres:9.5-alpine
    networks:
      - jiranet
    volumes:
      - ./postgresqldata/:/var/lib/postgresql/data
    environment:
      - 'POSTGRES_USER=jira'
      # CHANGE THE PASSWORD!
      - 'POSTGRES_PASSWORD=jellyfish'
      - 'POSTGRES_DB=jiradb'
      - 'POSTGRES_ENCODING=UNICODE'
      - 'POSTGRES_COLLATE=C'
      - 'POSTGRES_COLLATE_TYPE=C'
    logging:
      # limit logs retained on host to 25MB
      driver: "json-file"
      options:
        max-size: "500k"
        max-file: "50"

volumes:
  setupdata:
    external: false
  jiradata:
    external: false
  postgresqldata:
    external: false



networks:
  jiranet:
    driver: bridge

ownjira映像的Dockerfile:

FROM teamatldocker/jira

USER root

COPY *.obr /var/atlassian/jira/plugins/installed-plugins/

USER jira
CMD ["jira"]

任何我认为问题都在mvn-docker插件的JIRA_DATABASE_URL中或在网络设置中。但是我在那里尝试了许多不同的组合,如果更改主机,我将得到一个主机无法访问的主机,因此我认为网络工作正常。

任何想法可能有什么问题吗?

更新:附加信息:mysql而不是Postgresql或其他Postgresql版本也会发生相同的问题。

0 个答案:

没有答案