File tree Expand file tree Collapse file tree 5 files changed +62
-45
lines changed
docker-modules/docker-multi-module-maven
src/main/java/com/baeldung/api/controller Expand file tree Collapse file tree 5 files changed +62
-45
lines changed Original file line number Diff line number Diff line change 1- FROM maven:3.8.5-openjdk-17 AS MAVEN_TOOL_CHAIN
1+ FROM maven:3.8.5-openjdk-17 AS DEPENDENCEIS
22
3- COPY pom.xml /tmp/
4- COPY api /tmp/api/
5- COPY domain /tmp/domain/
3+ WORKDIR /opt/app
4+ COPY api/pom.xml api/pom.xml
5+ COPY domain/pom.xml domain/pom.xml
6+ COPY pom.xml .
67
7- WORKDIR /tmp/
8- RUN mvn clean install -X
8+ RUN mvn -B -e org.apache.maven.plugins:maven-dependency-plugin:3.1.2:go-offline -DexcludeArtifactIds=domain
99
10- FROM openjdk:17
10+ FROM maven:3.8.5-openjdk-17 AS BUILDER
1111
12- COPY --from=MAVEN_TOOL_CHAIN /tmp/api/target/docker-multi-module-maven-api-0.0.1-SNAPSHOT.jar /app.jar
12+ WORKDIR /opt/app
13+ COPY --from=DEPENDENCEIS /root/.m2 /root/.m2
14+ COPY --from=DEPENDENCEIS /opt/app/ /opt/app
15+ COPY api/src /opt/app/api/src
16+ COPY domain/src /opt/app/domain/src
17+
18+ RUN mvn -B -e clean install -DskipTests
19+
20+ FROM openjdk:17-slim
21+
22+ WORKDIR /opt/app
23+ COPY --from=BUILDER /opt/app/api/target/*.jar /app.jar
24+ EXPOSE 8080
1325
1426ENTRYPOINT ["java" , "-jar" , "/app.jar" ]
Original file line number Diff line number Diff line change 33 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
44 xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
55 <modelVersion >4.0.0</modelVersion >
6- <artifactId >docker-multi-module-maven- api</artifactId >
6+ <artifactId >api</artifactId >
77
88 <parent >
9- <groupId >com.baeldung</groupId >
10- <artifactId >docker-multi-module-maven- parent</artifactId >
9+ <groupId >com.baeldung.docker-multi-module-maven </groupId >
10+ <artifactId >parent</artifactId >
1111 <version >0.0.1-SNAPSHOT</version >
1212 </parent >
1313
1717 <artifactId >spring-boot-starter-web</artifactId >
1818 </dependency >
1919 <dependency >
20- <groupId >com.baeldung</groupId >
21- <artifactId >docker-multi-module-maven- domain</artifactId >
20+ <groupId >com.baeldung.docker-multi-module-maven </groupId >
21+ <artifactId >domain</artifactId >
2222 <version >0.0.1-SNAPSHOT</version >
2323 </dependency >
2424
2828 <scope >test</scope >
2929 </dependency >
3030 </dependencies >
31+
32+ <build >
33+ <plugins >
34+ <plugin >
35+ <groupId >org.springframework.boot</groupId >
36+ <artifactId >spring-boot-maven-plugin</artifactId >
37+ </plugin >
38+ <plugin >
39+ <groupId >com.google.cloud.tools</groupId >
40+ <artifactId >jib-maven-plugin</artifactId >
41+ <version >3.4.0</version >
42+ <configuration >
43+ <from >
44+ <image >openjdk:17-slim</image >
45+ </from >
46+ <to >
47+ <image >baeldung-demo:v2.2</image >
48+ </to >
49+ <container >
50+ <mainClass >com.baeldung.api.Application</mainClass >
51+ <ports >
52+ <port >8080</port >
53+ </ports >
54+ </container >
55+ </configuration >
56+ </plugin >
57+ </plugins >
58+ </build >
3159</project >
Original file line number Diff line number Diff line change @@ -20,9 +20,10 @@ public CountriesController(CountryRepository countries) {
2020
2121 @ GetMapping ("api/countries" )
2222 public List <CountryDto > index () {
23+
2324 Iterable <Country > all = countries .findAll ();
2425 return stream (all .spliterator (), false )
25- .map (it -> new CountryDto (it .getId (), it .getName (), it .getIso (), null ))
26+ .map (it -> new CountryDto (it .getId (), it .getName (), it .getIso (), it . getEmoji () ))
2627 .collect (toList ());
2728 }
2829
Original file line number Diff line number Diff line change 33 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
44 xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
55 <modelVersion >4.0.0</modelVersion >
6- <artifactId >docker-multi-module-maven- domain</artifactId >
6+ <artifactId >domain</artifactId >
77 <packaging >jar</packaging >
88
99 <parent >
10- <groupId >com.baeldung</groupId >
11- <artifactId >docker-multi-module-maven- parent</artifactId >
10+ <groupId >com.baeldung.docker-multi-module-maven </groupId >
11+ <artifactId >parent</artifactId >
1212 <version >0.0.1-SNAPSHOT</version >
1313 </parent >
1414
2828 <scope >test</scope >
2929 </dependency >
3030 </dependencies >
31-
32- <build >
33- <plugins >
34- <!-- Override Spring Boot plugin in this module to prevent it from running -->
35- <plugin >
36- <groupId >org.springframework.boot</groupId >
37- <artifactId >spring-boot-maven-plugin</artifactId >
38- <executions >
39- <execution >
40- <id >repackage</id >
41- <phase >none</phase >
42- </execution >
43- </executions >
44- </plugin >
45- </plugins >
46- </build >
47-
4831</project >
Original file line number Diff line number Diff line change 33 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
44 xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
55 <modelVersion >4.0.0</modelVersion >
6- <groupId >com.baeldung</groupId >
7- <artifactId >docker-multi-module-maven-parent</artifactId >
6+
7+ <groupId >com.baeldung.docker-multi-module-maven</groupId >
8+ <artifactId >parent</artifactId >
89 <packaging >pom</packaging >
910 <version >0.0.1-SNAPSHOT</version >
1011
1112 <parent >
1213 <groupId >org.springframework.boot</groupId >
1314 <artifactId >spring-boot-starter-parent</artifactId >
1415 <version >3.3.2</version >
16+ <relativePath />
1517 </parent >
1618
1719 <modules >
1820 <module >api</module >
1921 <module >domain</module >
2022 </modules >
21-
22- <build >
23- <plugins >
24- <plugin >
25- <groupId >org.springframework.boot</groupId >
26- <artifactId >spring-boot-maven-plugin</artifactId >
27- </plugin >
28- </plugins >
29- </build >
3023</project >
You can’t perform that action at this time.
0 commit comments