Skip to content

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

@weltonrodrigo

Description

@weltonrodrigo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions