Skip to content

Commit

Permalink
Ensures that /root/.m2 is pre-populated
Browse files Browse the repository at this point in the history
If the local maven repository, the `/root/.m2` directory in this case, is empty, then the first time that `mvn` runs a plugin, such as `org.cyclonedx:cyclonedx-maven-plugin:makeAggregateBom` or `com.corgibytes:versions-maven-plugin:resolve-ranges-historical`, then the `mvn` process downloads all of the dependencies and stores them in the local repository. This can create problems if there are two instances of `mvn` running at the same time, both attempting to download the same files, but at different times. By forcing the two plugins that are run by `freshli-agent-java` to run on a minimal `pom.xml` file while the container is being built, this change ensures that the `/root/.m2` directory is populated. Hopefully, this means that the `mvn` process won't need to download those files, and instead will just run using the copies that are already stored locally. This will avoid issues with having two instances of `mvn` running at the same time.
  • Loading branch information
mscottford committed Nov 1, 2022
1 parent 680adbf commit 005b40d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
RUN mkdir -p $MAVEN_CONFIG

# Bootstrap contents of .m2 directory
RUN mkdir /root/bootstrap
RUN echo "<project> \
<groupId>com.corgibytes</groupId> \
<artifactId>freshli-java-bootstrap</artifactId> \
<version>1.0</version> \
<modelVersion>4.0.0</modelVersion> \
</project>" > /root/bootstrap/pom.xml
RUN cd /root/bootstrap && \
mvn org.cyclonedx:cyclonedx-maven-plugin:makeAggregateBom && \
mvn com.corgibytes:versions-maven-plugin:resolve-ranges-historical

# Copy `freshli` executable from the `dotnet_build` image
RUN mkdir -p /usr/local/share/freshli
COPY --from=dotnet_build /app/freshli/exe/ /usr/local/share/freshli/
Expand Down

0 comments on commit 005b40d

Please sign in to comment.