Skip to content

Commit 15331ab

Browse files
committed
Optimize built image
Use multi-stage build to only have eclipse-temurin:21-jre-alpine being used when running the app. Also don't copy the entire target directory but rather just use the zip with only the necessary files needed to run the application. JIRA: LIGHTY-353 Signed-off-by: tobias.pobocik <tobias.pobocik@pantheon.tech>
1 parent 3587fbc commit 15331ab

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Dockerfile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,20 @@ RUN mvn install -DskipTests
1212

1313
WORKDIR /lighty-netconf-simulator/examples/devices/lighty-network-topology-device
1414

15-
RUN cp target/lighty-network-topology-device-$VERSION.jar target/lighty-network-topology-device.jar
15+
RUN unzip target/lighty-network-topology-device-$VERSION-bin.zip -d target/
16+
17+
RUN mv target/lighty-network-topology-device-$VERSION target/lighty-network-topology-device
18+
RUN mv target/lighty-network-topology-device/lighty-network-topology-device-$VERSION.jar target/lighty-network-topology-device/lighty-network-topology-device.jar
19+
20+
FROM eclipse-temurin:21-jre-alpine
21+
22+
ARG VERSION
23+
24+
COPY --from=build /lighty-netconf-simulator/examples/devices/lighty-network-topology-device/target/lighty-network-topology-device /app/target
25+
COPY --from=build /lighty-netconf-simulator/examples/devices/lighty-network-topology-device/src/main/resources /app/target/resources
26+
27+
WORKDIR /app/target
1628

1729
EXPOSE 17380
1830

19-
ENTRYPOINT ["java", "-jar", "target/lighty-network-topology-device.jar"]
31+
ENTRYPOINT ["java", "-jar", "lighty-network-topology-device.jar"]

0 commit comments

Comments
 (0)