Skip to content

Commit c413e57

Browse files
Don't build directly in the home dir
1 parent af29ee2 commit c413e57

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

docker/Dockerfile

+8-6
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@
1212
FROM registry.access.redhat.com/ubi8/openjdk-17:1.15-1.1682053058 AS builder
1313

1414
# Build dependency offline to streamline build
15+
RUN mkdir project
16+
WORKDIR /home/jboss/project
1517
COPY pom.xml .
1618
RUN mvn dependency:go-offline
1719

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

2628
FROM registry.access.redhat.com/ubi8/openjdk-17-runtime:1.15-1.1682053056
27-
COPY --from=builder /home/jboss/target/export-run-artifact.jar /deployments/export-run-artifact.jar
29+
COPY --from=builder /home/jboss/project/target/export-run-artifact.jar /deployments/export-run-artifact.jar
2830
EXPOSE 8081
2931
ENTRYPOINT ["/opt/jboss/container/java/run/run-java.sh", "--server.port=8081"]
3032

0 commit comments

Comments
 (0)