File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ # First stage: JDK build
2
+ FROM openjdk:17 AS build
3
+
4
+ # Update package lists and Install Maven
5
+ RUN microdnf update -y && \
6
+ microdnf install -y maven && \
7
+ microdnf clean all
8
+
9
+ WORKDIR /usr/src/app
10
+
11
+ # Copy the Maven dependencies.
12
+ COPY pom.xml .
13
+ RUN mvn dependency:go-offline
14
+
15
+ # Copy the application source code
16
+ COPY src/ ./src/
17
+ COPY frontend/ ./frontend/
18
+
19
+ # # Do the build
20
+ RUN mvn clean install -Pproduction
21
+
22
+ # Second stage: Lightweight jdk-slim image
23
+ FROM openjdk:17-jdk-slim
24
+ RUN useradd -m appuser
25
+
26
+ RUN mkdir /app && \
27
+ chown -R appuser /app
28
+
29
+ USER appuser
30
+
31
+ WORKDIR /app
32
+
33
+ # Copy the native binary from the build stage
34
+ COPY --from=build /usr/src/app/target/*.jar /app/app.jar
35
+
36
+ # Run the application
37
+ EXPOSE 8080
38
+ ENTRYPOINT ["java" , "-jar" , "/app/app.jar" ]
You can’t perform that action at this time.
0 commit comments