'Docker image for multi-maven modules (Hexagonal Architecture)
I am trying to create a docker image with a dockerfile with multiple maven modules and I faced alot of erros. Here is my architecture
+ -- MyMainProject
+ -- application <- Module 1
| ` -- pom.xml
+ -- domain <- Module 2
| ` -- pom.xml
+ -- bootloader <- Module 3
| `src/main/java/BootloaderApplicationLuncher (Java application launcher)
| ` -- pom.xml
+ -- infrastructure <- Module 4 (has 3 modules)
+ -- infrastructure 1 <- Module 4.1
| ` -- pom.xml
+ -- infrastructure 2 <- Module 4.2
| ` -- pom.xml
+ -- infrastructure 3 <- Module 4.3
| ` -- pom.xml
| -- pom.xml
Here is my dockerfile:
FROM maven:3.6-alpine as build
WORKDIR /home/app
COPY application/pom.xml application/pom.xml
COPY domain/pom.xml domain/pom.xml
COPY bootloader/pom.xml bootloader/pom.xml
COPY infrastructure/pom.xml infrastructure/pom.xml
COPY infrastructure/adapter-persistence-spring-data-jpa/pom.xml infrastructure/adapter-persistence-spring-data-jpa/pom.xml
COPY infrastructure/adapter-persistence-spring-data-mongodb/pom.xml infrastructure/adapter-persistence-spring-data-mongodb/pom.xml
COPY infrastructure/adapter-rest/pom.xml infrastructure/adapter-rest/pom.xml
COPY pom.xml .
RUN mvn -B -e -C org.apache.maven.plugins:maven-dependency-plugin:3.1.2:go-offline
RUN mvn -f /home/app/pom.xml clean package
FROM maven:3.6-alpine as BUILDER
COPY --from=build /root/.m2 /root/.m2
COPY --from=build /home/app /home/app
COPY application/src /home/app/application/src
COPY domain/src /home/app/domain/src
COPY bootloader/src /home/app/bootloader/src
COPY infrastructure/src /home/app/infrastructure/src
COPY infrastructure/adapter-rest/src /home/app/infrastructure/adapter-rest/src
COPY infrastructure/adapter-persistence-spring-data-mongodb/src /home/app/infrastructure/adapter-persistence-spring-data-mongodb/src
COPY infrastructure/adapter-persistence-spring-data-jpa/src /home/app/infrastructure/adapter-persistence-spring-data-jpa/src
#RUN mvn -B -e clean install -DskipTests=true
FROM openjdk:8-alpine
EXPOSE 8080
WORKDIR /home/app
COPY --from=builder /home/app/bootloader/target/bootloader-1.0-SNAPSHOT.jar .
ENTRYPOINT ["java", "-jar", "/home/app/bootloader/bootloader-1.0-SNAPSHOT.jar"]
Error: Failed to execute goal on project application: Could not resolve dependencies for project io.example:application:jar:1.0-SNAPSHOT: Could not find artifact io.example:domain:jar:1.0-SNAPSHOT in spring-releases (https://repo.spring.io/libs-release) -> [Help 1]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
