我正在使用 maven jib 插件来对基于 Spring boot 的应用程序进行 dockerize。
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 run -v /local/path/config/:/secrets/ IMAGE:1.0 bash "java -cp /app/libs/*:/app/resources/:/app/classes/ -Xmx2g -Xms2g com.test.Application --spring.config.location=/secrets/application.yml"