generated from vaadin/addon-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# First stage: JDK build | ||
FROM openjdk:17 AS build | ||
|
||
# Update package lists and Install Maven | ||
RUN microdnf update -y && \ | ||
microdnf install -y maven && \ | ||
microdnf clean all | ||
|
||
WORKDIR /usr/src/app | ||
|
||
# Copy the Maven dependencies. | ||
COPY pom.xml . | ||
RUN mvn dependency:go-offline | ||
|
||
# Copy the application source code | ||
COPY src/ ./src/ | ||
COPY frontend/ ./frontend/ | ||
|
||
## Do the build | ||
RUN mvn clean install -Pproduction | ||
|
||
# Second stage: Lightweight jdk-slim image | ||
FROM openjdk:17-jdk-slim | ||
RUN useradd -m appuser | ||
|
||
RUN mkdir /app && \ | ||
chown -R appuser /app | ||
|
||
USER appuser | ||
|
||
WORKDIR /app | ||
|
||
# Copy the native binary from the build stage | ||
COPY --from=build /usr/src/app/target/*.jar /app/app.jar | ||
|
||
# Run the application | ||
EXPOSE 8080 | ||
ENTRYPOINT ["java", "-jar", "/app/app.jar"] |