我正在制作一个Docker镜像,该镜像在运行时执行Maven任务。它看起来有点像这样:
ADD pom.xml /srv
ADD src /srv/src
WORKDIR /srv
RUN mvn dependencies:go-offline scala:testCompile
在运行时,我正在运行mvn gatling:execute
来运行一个负载测试工具。
我的POM文件如下:
<project>
<dependencies>
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-core</artifactId>
<version>${gatling.version}</version>
</dependency>
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-http</artifactId>
<version>${gatling.version}</version>
</dependency>
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-app</artifactId>
<version>${gatling.version}</version>
</dependency>
<dependency>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts</artifactId>
<version>${gatling.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
我希望的是,当我最终运行
mvn gatling:execute
时,不需要下载任何依赖项,而是想在构建时将它们全部打包到镜像中。然而,即使执行
mvn dependencies:go-offline scala:testCompile
也不能完全满足我的需求。运行gatling:execute
仍然需要下载更多的依赖项。如何在Docker镜像中下载Maven所需的所有内容,以便在运行时不需要进行任何下载?
gatling:execute
而不会大规模攻击一个端点 ;) - Naftuli Kay