Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please allow some kind of cache for the sake of docker builds #367

Open
weltonrodrigo opened this issue Jul 31, 2023 · 0 comments
Open

Please allow some kind of cache for the sake of docker builds #367

weltonrodrigo opened this issue Jul 31, 2023 · 0 comments

Comments

@weltonrodrigo
Copy link

Hi.

The following Dockerfile would work wonderfully if we somehow could cache the deps for the wildfly-jar-maven-plugin in the dependencies phase.

Something like mvn wildfly-jar:go-offline.

FROM maven:3-openjdk-11 as dependencies

WORKDIR /opt/app
COPY pom.xml /opt/app

# Download deps (this layer gets cached)
RUN mvn -Dmaven.repo.local=/opt/app/m2  --no-transfer-progress  \
    de.qaware.maven:go-offline-maven-plugin:resolve-dependencies


# Application build
FROM maven:3-openjdk-11 as build

WORKDIR /opt/app

# Copy deps from `dependencies` phase

COPY --from=dependencies /opt/app/m2 /opt/app/m2

# copy files need to build the application
COPY scripts /opt/app/scripts
COPY pom.xml /opt/app/
COPY src/ /opt/app/src/

# Do the build 
# Unfortunately 😢 the deps for the wildfly jar plugin are not cached in the first phase
# resulting in 296 files being downloaded everytime
RUN mvn -Dmaven.repo.local=/opt/app/m2 package -B --no-transfer-progress

FROM openjdk:11-jdk-slim as assemble


# App artifact
COPY --from=build /opt/app/target/*.jar /app/app.jar

ENTRYPOINT ["/usr/local/openjdk-11/bin/java", "-jar", "/app/app.jar"]

Had we any way to download all dependencies based on the pom.xml, the docker workflow would be much better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant