-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
39 lines (30 loc) · 971 Bytes
/
Dockerfile
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
# First stage: JDK build
FROM maven:3.6.3-openjdk-17-slim AS prepare-build
# Create buildtime user and directory
RUN useradd -m appbuilder
RUN mkdir /build && \
chown -R appbuilder /build
WORKDIR /build
USER appbuilder
# Copy rest of the dependencies.
COPY --chown=appbuilder pom.xml .
RUN mvn dependency:go-offline
FROM prepare-build AS build-app
USER appbuilder
# Copy the source code. Note expect to have .dockerignore that ignores
COPY --chown=appbuilder . .
## Do Vaadin production build
RUN mvn clean install -Pproduction
# Create runtime from lightweight jdk-slim image
FROM openjdk:17-jdk-slim AS runtime
# Create runtime user and directory
RUN useradd -m appuser
RUN mkdir /app && \
chown -R appuser /app
WORKDIR /app
# Copy the native binary from the build stage
COPY --from=build-app --chown=appuser /build/target/vaadin-cors-sample-*.jar /app/app.jar
# Run the application
USER appuser
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app/app.jar"]