Skip to content

Commit e3ae644

Browse files
authored
Merge pull request #16 from jduimovich/compute-artifact-name
Compute the name of the built jar in the Dockerfile
2 parents 5b61a7b + e72ad94 commit e3ae644

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

docker/Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ COPY pom.xml .
1818
RUN mvn dependency:go-offline
1919

2020
COPY src src
21-
RUN mvn package -Dmaven.test.skip=true
21+
RUN mvn package -Dmaven.test.skip=true
22+
# compute the created jar name and put it in a known location to copy to the next layer.
23+
# If the user changes pom.xml to have a different version, or artifactId, this will find the jar
24+
RUN grep version /build/target/maven-archiver/pom.properties | cut -d '=' -f2 >.env-version
25+
RUN grep artifactId /build/target/maven-archiver/pom.properties | cut -d '=' -f2 >.env-id
26+
RUN mv /build/target/$(cat .env-id)-$(cat .env-version).jar /build/target/export-run-artifact.jar
2227

2328
FROM openjdk:11-jdk
24-
COPY --from=0 /build/target/demo-0.0.1-SNAPSHOT.jar /app/target/demo-0.0.1-SNAPSHOT.jar
29+
COPY --from=0 /build/target/export-run-artifact.jar /app/target/export-run-artifact.jar
2530

2631
EXPOSE 8081
27-
ENTRYPOINT [ "java", "-jar", "/app/target/demo-0.0.1-SNAPSHOT.jar", "--server.port=8081" ]
32+
ENTRYPOINT [ "java", "-jar", "/app/target/export-run-artifact.jar", "--server.port=8081" ]

0 commit comments

Comments
 (0)