-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (27 loc) · 769 Bytes
/
Copy pathDockerfile
File metadata and controls
39 lines (27 loc) · 769 Bytes
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
# ===============================
# Build Stage
# ===============================
FROM maven:3.9.9-eclipse-temurin-17 AS build
WORKDIR /app
# Cache dependencies
COPY pom.xml .
RUN mvn -B -q -e -DskipTests dependency:go-offline
# Copy source
COPY src ./src
# Build jar
RUN mvn clean package -DskipTests
# ===============================
# Runtime Stage
# ===============================
FROM eclipse-temurin:17-jre-alpine
WORKDIR /app
# Create non-root user
RUN addgroup -S spring && adduser -S spring -G spring
# Copy jar
COPY --from=build /app/target/*.jar app.jar
# Switch to non-root
USER spring
# Default port
ENV PORT=8080
EXPOSE 8080
ENTRYPOINT ["sh", "-c", "java -XX:+UseContainerSupport -XX:MaxRAMPercentage=75.0 -jar app.jar --server.port=${PORT}"]