My dockerfile for gradle spring boot application
FROM gradle:8.12.0-jdk21-alpine as build
WORKDIR /app
COPY --chown=gradle:gradle . /app
RUN gradle clean assemble
FROM eclipse-temurin:21.0.5_11-jre-noble as builder
WORKDIR /app
COPY --from=build /app/build/libs/*.jar /app/app.jar
RUN java -Djarmode=layertools -jar app.jar extract
FROM eclipse-temurin:21.0.5_11-jre-noble
WORKDIR /app
COPY --from=builder app/dependencies/ ./
COPY --from=builder app/spring-boot-loader/ ./
COPY --from=builder app/snapshot-dependencies/ ./
COPY --from=builder app/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
If I use dependencies with mavenCentral(), then there are no problems.
But if I have several mevenLocal() dependencies ONLY, then the build at this step causes an error because there is no connection to the local repository(/home/<User_Name>/.m2
).
How do I make a connection between the first stage of the build and my local repository?
I use gitlab as a remote repository. Created a private maven repository in gitlab. https://docs.gitlab.com/ee/user/packages/maven_repository
When the dockerfile is running, dependencies are loaded from it.