【发布时间】:2019-06-08 13:32:43
【问题描述】:
我正在使用 maven jib 插件来对接我基于 Spring Boot 的应用程序。
https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/main/resources/static</directory>
</resource>
</resources>
<outputDirectory>${project.build.directory}/webapp/static</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>0.9.13</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<from>
<image>${base.image}</image>
</from>
<to>
<image>${registry}/${repository}/${image}:${version}</image>
</to>
<extraDirectory>${project.build.directory}/webapp</extraDirectory>
</configuration>
</plugin>
我在 JIB 插件中没有 args 或 Entrypoint。我想通过参数来控制它。
在运行“mvn clean install”时,我在日志中看到以下行。
Container entrypoint set to [java, -cp, /app/resources:/app/classes:/app/libs/*, com.test.Application]
我尝试将 --spring.config.location 作为程序参数传递如下。但它没有选择我的 application.properties。我尝试修改起始类名以检查它是否正常工作,但它仍在使用 com.test.Application。看起来,这里没有考虑-c。
docker 运行 -v /local/path/config/:/secrets/ 图片:1.0 bash "java -cp /app/libs/*:/app/resources/:/app/classes/ -Xmx2g -Xms2g com.test.Application --spring.config.location=/secrets/application.yml"
【问题讨论】:
-
如何将
/secrets/application.yml注入容器中?
标签: spring-boot docker jib