-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile_App
51 lines (40 loc) · 1.4 KB
/
Dockerfile_App
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Stage 1: Build Custom JRE and Package the App
FROM eclipse-temurin:21-jdk-noble AS builder
# Install Maven
RUN apt-get update && apt-get install -y maven && rm -rf /var/lib/apt/lists/*
# Copy the project files and build the application
COPY pom.xml .
COPY src ./src
# Run Maven to build the application
RUN mvn clean package -DskipTests=true
# Copy the compiled application to the container
COPY target/api-doc-crafter.jar service.jar
# Create minimal JRE
RUN MODULES=$(jdeps --print-module-deps --ignore-missing-deps --class-path service.jar service.jar | tail -n1) && \
jlink \
--add-modules ${MODULES} \
--strip-native-commands \
--strip-debug \
--no-man-pages \
--no-header-files \
--output /custom-jre
# Create executable
RUN mkdir -p jp_tmp && cp service.jar jp_tmp/ && \
jpackage \
--input jp_tmp \
--name service \
--main-jar service.jar \
--runtime-image /custom-jre \
--type app-image
# USED TO EXPORT THE JAR FILE
# [SYSTEM] docker build --target export . --output target
FROM scratch AS export
COPY --from=builder /service /service
# Final Stage: Minimal Runtime Image
FROM debian:stable-slim
# Copy packaged app and additional files
COPY --from=builder /service /service
# Expose the necessary port
EXPOSE 8080
# Use bash for variable substitution and proper PID management
ENTRYPOINT ["/bin/bash", "-c", "exec /service/bin/service"]