-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (26 loc) · 1.16 KB
/
Copy pathDockerfile
File metadata and controls
34 lines (26 loc) · 1.16 KB
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
# ==============================================================================
# Build Stage
# ==============================================================================
FROM maven:3.9.6-eclipse-temurin-21-alpine AS builder
WORKDIR /app
# Copy pom.xml and actual source code to build the package
COPY pom.xml .
COPY src ./src
RUN mvn clean package -DskipTests
# ==============================================================================
# Runtime Stage
# ==============================================================================
FROM eclipse-temurin:21-jre-alpine AS runner
WORKDIR /app
# Create a secure, non-privileged system group and user
RUN addgroup -S sovereign && adduser -S sovereign -G sovereign
# Copy the compiled JAR from the builder stage
COPY --from=builder /app/target/sovereign-comm-platform-0.1.0-SNAPSHOT.jar app.jar
# Set ownership of the runtime assets to the non-root user
RUN chown -R sovereign:sovereign /app
# Switch to the non-root user for security hardening
USER sovereign
# Expose the default Spring Boot port
EXPOSE 8080
# Configure execution entrypoint
ENTRYPOINT ["java", "-XX:+UseG1GC", "-XX:MaxRAMPercentage=75.0", "-jar", "app.jar"]