-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (31 loc) · 1004 Bytes
/
Dockerfile
File metadata and controls
42 lines (31 loc) · 1004 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
40
41
42
# Multi-stage build for API Gateway
FROM eclipse-temurin:17-jdk-alpine AS builder
WORKDIR /app
# Copy Maven wrapper and pom.xml first (for caching)
COPY mvnw .
COPY .mvn .mvn
COPY pom.xml .
# Download dependencies (cached layer)
RUN ./mvnw dependency:go-offline -B
# Copy source code and build
COPY src src
RUN ./mvnw package -DskipTests
# Runtime stage
FROM eclipse-temurin:17-jre-alpine
WORKDIR /app
# Add non-root user for security
RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring
# Copy the JAR from builder stage
COPY --from=builder /app/target/*.jar app.jar
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=5 \
CMD wget --no-verbose --tries=1 --spider http://localhost:9191/actuator/health || exit 1
# Expose port
EXPOSE 9191
# JVM optimization for containers
ENTRYPOINT ["java", \
"-XX:+UseContainerSupport", \
"-XX:MaxRAMPercentage=75.0", \
"-Djava.security.egd=file:/dev/./urandom", \
"-jar", "app.jar"]