Skip to content

Commit dc26f98

Browse files
committed
Added demo docker build
1 parent 5e8dcb3 commit dc26f98

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

demo/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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"]

0 commit comments

Comments
 (0)