I'm trying to build a scala project with docker Multi-Stage ability.
For starter, this is my dockerfile:
FROM maven:3.6.0-jdk-11-slim AS maven
RUN apt-get update
WORKDIR /build
COPY pom.xml .
RUN mvn -B de.qaware.maven:go-offline-maven-plugin:resolve-dependencies
COPY src src
RUN mvn -B -o install spring-boot:repackage
FROM openjdk:11.0.6
WORKDIR /opt/app
COPY --from=maven /build/target/app.jar app.jar
CMD ["java", "-jar", "/opt/app/app.jar"]
EXPOSE 8080
I noticed that after finishing the resolve-dependencies part, maven still trying to download dependencies on install stage. The errors that I get are related to the scala-maven-plugin that looking for non-existing dependencies that didn't fetched in the resolving stage. The errors looks like this:
Failed to execute goal
net.alchim31.maven:scala-maven-plugin:3.4.0:compile (default) on
project app: wrap:
org.apache.maven.artifact.resolver.ArtifactNotFoundException: Cannot
access ... in
offline mode and the artifact
org.scala-lang:scala-compiler:jar:2.11.12 has not been downloaded from
it before.
Even adding this dependency isn't enough because it fails on another dependecies.
The plugin in the POM looks like that:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<goals>
<!-- Need to specify this explicitly, otherwise plugin won't be called when doing e.g. mvn compile -->
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<args>
<!-- work-around for https://issues.scala-lang.org/browse/SI-8358 -->
<arg>-nobootcp</arg>
<arg>-Yresolve-term-conflict:package</arg>
</args>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
Seems like the plugin doesn't stop there and download everything again.
Thanks guys..
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…