-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (27 loc) · 958 Bytes
/
Dockerfile
File metadata and controls
39 lines (27 loc) · 958 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
# Multi-stage build: compile with JDK
FROM eclipse-temurin:21-jdk AS builder
WORKDIR /build
# Copy Gradle wrapper and configuration
COPY gradlew .
COPY gradle gradle
COPY build.gradle.kts .
COPY settings.gradle.kts .
# Copy source code
COPY src src
# Build the application
RUN chmod +x ./gradlew && ./gradlew bootJar --no-daemon
# Runtime stage: minimal JRE image
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app
# Copy JAR from builder stage
COPY --from=builder /build/build/libs/*.jar app.jar
# Create non-root user for security
RUN addgroup -g 1000 appuser && adduser -D -u 1000 -G appuser appuser
USER appuser
# Expose port
EXPOSE 8080
# Health check using Actuator
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/actuator/health || exit 1
# Run the application with prod profile
ENTRYPOINT ["java", "-jar", "app.jar", "--spring.profiles.active=prod"]