|
1 | | -# fetch basic image |
2 | | -FROM maven:3.9.9-eclipse-temurin-17 |
| 1 | +################################################################################################### |
| 2 | +# Stage 1: Build the application |
| 3 | +################################################################################################### |
3 | 4 |
|
4 | | -# application placed into /opt/app |
5 | | -RUN mkdir -p /app |
| 5 | +FROM dhi.io/maven:3-jdk17-debian13-dev AS build |
6 | 6 | WORKDIR /app |
7 | 7 |
|
8 | | -# selectively add the POM file and |
9 | | -# install dependencies |
10 | | -COPY pom.xml /app/ |
11 | | -RUN mvn install |
| 8 | +# selectively add the POM file and install dependencies |
| 9 | +COPY pom.xml . |
| 10 | +RUN mvn dependency:go-offline -B |
12 | 11 |
|
13 | | -# rest of the project |
14 | | -COPY src /app/src |
| 12 | +# add the src and package it |
| 13 | +COPY src src |
15 | 14 | RUN mvn package |
16 | 15 |
|
17 | | -# local application port |
18 | | -EXPOSE 8080 |
| 16 | +################################################################################################### |
| 17 | +# Stage 2: Create the final runtime image |
| 18 | +################################################################################################### |
| 19 | + |
| 20 | +FROM dhi.io/eclipse-temurin:17-debian13 |
| 21 | +WORKDIR /app |
19 | 22 |
|
20 | | -# execute it |
21 | | -# CMD ["mvn", "exec:java"] |
22 | | -CMD ["java", "-jar", "target/cqlTranslationServer-2.9.0.jar", "-d"] |
| 23 | +# copy the translation service jar and dependency libs from the previous build |
| 24 | +COPY --from=build /app/target/cqlTranslationServer-*.jar cqlTranslationServer.jar |
| 25 | +COPY --from=build /app/target/libs libs/ |
| 26 | + |
| 27 | +# Expose the port and run it! |
| 28 | +EXPOSE 8080 |
| 29 | +ENTRYPOINT ["java","-jar","/app/cqlTranslationServer.jar", "-d"] |
0 commit comments