Skip to content

Commit 4e40273

Browse files
committed
feat: add Dockerfile for eureka-server with multi-stage build and health check configuration
1 parent 0ad5b7f commit 4e40273

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

vm-deploy/eureka-server/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Build stage
2+
FROM amazoncorretto:17-alpine as builder
3+
WORKDIR /app
4+
COPY eureka-server.jar app.jar
5+
RUN apk add --no-cache binutils \
6+
&& jlink \
7+
--add-modules java.base,java.logging,java.xml,java.sql,java.naming,java.desktop,java.security.jgss,java.instrument,jdk.unsupported \
8+
--strip-debug \
9+
--no-man-pages \
10+
--no-header-files \
11+
--compress=2 \
12+
--output /javaruntime
13+
14+
# Runtime stage
15+
FROM alpine:3.18
16+
ENV JAVA_HOME=/javaruntime
17+
ENV PATH="${JAVA_HOME}/bin:${PATH}"
18+
COPY --from=builder /javaruntime $JAVA_HOME
19+
COPY --from=builder /app/app.jar /app.jar
20+
21+
# Create non-root user
22+
RUN addgroup -S spring && adduser -S spring -G spring
23+
USER spring:spring
24+
25+
# Configure health check
26+
HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
27+
CMD wget -q --spider http://localhost:8761/actuator/health || exit 1
28+
29+
EXPOSE 8761
30+
ENTRYPOINT ["java", "-XX:+UseContainerSupport", "-XX:MaxRAMPercentage=75.0", "-jar", "/app.jar"]

0 commit comments

Comments
 (0)